How can I export Sphere packs to GTS or STL file?

Asked by S. Feng

Hi there,

I generated a sphere pack using the following codes.

import gts
from yade import pack
surf=gts.read(open('part.gts'))
pred=pack.inGtsSurface(surf)
spheres=pack.randomDensePack(pred,radius=15.75,rRelFuzz=0.42857)
O.bodies.append(spheres)

I want to use this sphere pack as a geometry model for following FEM simulations. However, now I am facing a problem that I don't know how I can export these spheres into a GTS or STL file. Because I am a new-beginner on Yade, could you please help me with it? Thanks.

Regards,

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,
have a look at recent discussion on this topic [1]
cheers
Jan

[1] https://answers.launchpad.net/yade/+question/688822

Revision history for this message
S. Feng (scfeng) said :
#2

Thanks Jan,

The reference you posted seems to address my problem. However, when I tried to run the codes you provided in that discussion, something was wrong as follows,

Traceback (most recent call last):
  File "/usr/bin/yade", line 182, in runScript
    execfile(script,globals())
  File "code.py", line 95, in <module>
    spheres2stl("sphs.stl")
  File "code.py", line 83, in spheres2stl
    triangles = [t.toStlFacet() for t in triangles]
  File "code.py", line 39, in toStlFacet
    normal = minieigen2stl(normal)
  File "code.py", line 36, in <lambda>
    minieigen2stl = lambda v: stl.Vector3d(*tuple(v))
AttributeError: 'module' object has no attribute 'Vector3d'

I searched on the Internet, but I failed to find a answer. Could you please provide any further help? Thanks.

Regards,

sc

Revision history for this message
S. Feng (scfeng) said :
#3

Hi Jan,

I tried to ran commands :

stl.Vector3d
stl.Facet
stl.Solid

However, all of these attributes were not found in module 'stl'. I guess the problem is my currently used stl package. I ran the command "pip install numpy-stl" to install the stl module. However, I have no idea how to solve this problem.

Revision history for this message
Jan Stránský (honzik) said :
#4

Hello,
as mentioned in [1] in a comment, the code was done using this stl package [2]. But I think with the other package it could be similar..
Jan

[2] https://pypi.org/project/stl/

Revision history for this message
S. Feng (scfeng) said :
#5

Hi Jan,

Thanks for your information.

I solved the problem by upgrading pip, and generated stl file successfully using your codes.

However, there is still one problem. The stl geometry used in most FEM softwares should be solid but not surfaces only. Namely, it is similar to mesh the spheres including their interior but not only their surfaces. Is there method to achieve this goal?

Regards,

sc

Revision history for this message
Jan Stránský (honzik) said :
#6

> The stl geometry used in most FEM softwares should be solid but not surfaces only.

Both GTS ("GNU Triangulated Surface", [3]) and STL ("Standard Triangle Language", [4]) describe only the surface AFAIK.
And because the question explicitly mentioned GTS and STL, the answer too :-)

> Is there method to achieve this goal?

Of course. You have all necessary data (centers and radii of the spheres), you can do whatever you like, e.g.:
- create the bulk mesh "manually" (like "manual" surface triangulation in [1])
- use a dedicated meshing software
- ...

The right approach strongly depends on your needs ("following FEM simulations" nor "most FEM softwares" gives much information).
In any case, the topic now became not so much related to Yade and I am not sure if you can get the answer here.

I suggest to open a new question, explicitly mentioning the "solid mesh" (some people who could answer the "solid mesh" problem might have stopped following this thread expecting the "surface mesh" problem)

cheers
Jan

[3] http://gts.sourceforge.net/
[4] https://en.wikipedia.org/wiki/STL_(file_format)

Can you help with this problem?

Provide an answer of your own, or ask S. Feng for more information if necessary.

To post a message you must log in.