Heterogeneous complex material shape

Asked by Christoph Tuitz on 2020-08-29

Hi,

I know there are ways to use the plane equation to check if a DE is in the positive or negative halfspace (question/256038) to be able to delete it or assign properties. But what if I want to check if a DE is inside a complex shaped mesh, eg a surface that is created by superposed folding like a egg container.

I read about another method in which rays are send out and depending on if the number of mesh intersections are even or odd the DE is outside or inside. It sounds pretty easy but the detection of intersections is not so straight forward. Anyway if it is necessary I will do it.

Before I go that route is there something already in YADE that I can use instead?

Thanks
Chris

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2020-08-30
Last query:
2020-08-30
Last reply:
2020-08-29
Best Jan Stránský (honzik) said : #1

Hello,

as discussed in mentioned question/256038, you can use pack.inGtsSurface for this purpose:
###
import gts
from yade import pack
horseFile = "/home/honzik/programs/yade/trunk/examples/gts-horse/horse.coarse.gts"
with open(horseFile) as f:
   horse = gts.read(f)
horse.scale(100,100,100)
O.bodies.append(pack.gtsSurface2Facets(horse))
s1 = sphere((0,0,0),1)
s2 = sphere((2,0,0),1)
s3 = sphere((4,0,0),1)
sphs = (s1,s2,s3)
O.bodies.append(sphs)

pred = pack.inGtsSurface(horse)
for sph in sphs:
   center = sph.state.pos
   radius = sph.shape.radius
   # "call" the predicate to test if a sphere/point is inside
   print("sphere ({},{}) inside: {}".format(center,radius,pred(center,radius)))
   print("center {} inside: {}".format(center,pred(center,0)))
###
The "left" sphere is "almost" inside, but along -x axis it is outside, therefore the result False.

the testing horse.coarse.gts is part of yade project [1].
The inGtsSurface testing is not exact [2], it checks 6 points (center +- radius along 3 axes) to be inside the mesh. You can test more points "manually" if desired (line center in the above example)

the gts surface can be loaded from file or constructed programatically.

cheers
Jan

[1] https://gitlab.com/yade-dev/trunk/-/blob/master/examples/gts-horse/horse.coarse.gts
[2] https://yade-dem.org/doc/yade.pack.html#yade._packPredicates.inGtsSurface.__init__

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

> O.bodies.append(pack.gtsSurface2Facets(horse))

just a note, it is not needed to convert the surface to simulation, I put it there just for illustration. The surface can be just the surface for the point-inside-testing, no facets needed.

Christoph Tuitz (t-chris3) said : #3

Hi Jan,

cool that seems to work well, my surfaces are more complex than a simple plane, but not too crazy so it should work.

Thanks for the explanation!

Christoph Tuitz (t-chris3) said : #4

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