Heterogeneous complex material shape
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
|
#1 |
Hello,
as discussed in mentioned question/256038, you can use pack.inGtsSurface for this purpose:
###
import gts
from yade import pack
horseFile = "/home/
with open(horseFile) as f:
horse = gts.read(f)
horse.scale(
O.bodies.
s1 = sphere((0,0,0),1)
s2 = sphere((2,0,0),1)
s3 = sphere((4,0,0),1)
sphs = (s1,s2,s3)
O.bodies.
pred = pack.inGtsSurfa
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(
print("center {} inside: {}".format(
###
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:/
[2] https:/
Jan Stránský (honzik) said : | #2 |
> O.bodies.
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-
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.