gtsPFacet
Dear all,
I'm try to study how to create a PFacet with the "yade.gridpface
#
from yade import qt
from yade.gridpfacet import *
import gts, os.path, locale
locale.
'''
if you get "Error: unsupported locale setting"
-> type as root: "dpkg-reconfigure locales"
-> choose "en_US.UTF-8" (press space to choose)
'''
################
### ENGINES ###
################
O.engines=[
ForceResetter(),
InsertionSortC
Bo1_Wall_Aabb(),
Bo1_PFacet_
],sortThenColl
InteractionLoop(
[
Ig2_Wall_
],
[
Ip2_FrictMat_
[
Law2_
Law2_
Law2_
]),
GlobalStiff
NewtonIntegrat
]
#################
### MATERIAL ###
#################
O.materials.
O.materials.
###################
### IMPORT MESH ###
###################
radius=1e-02
wire=False
fixed=False
z=-1.2
color=[0,0,1]
nodesIds0,
nodesIds1,
nodesIds2,
#######
##### Wall ###
#######
O.bodies.
##########
## VIEW ##
##########
qt.Controller()
qtv = qt.View()
qtr = qt.Renderer()
qtr.light2=True
qtr.lightPos=
qtr.bgColor=[1,1,1]
qtv.ortho=True
O.saveTmp()
#
I copy the script into yade and run it, the errors appear:
#
Traceback (most recent call last):
File "/usr/bin/yade", line 336, in runScript
execfile(
File "/usr/lib/
exec_(code, myglobals, mylocals)
File "718.py", line 60, in <module>
nodesIds0,
File "/usr/lib/
surf=
FileNotFoundError: [Errno 2] No such file or directory: 'octahedron.gts'
#
It reminds me there is no 'octahedron.gts' file.But I don't know how to create this kind files. If there is anybody knowing about this, could you teach me how to create the gts files and show me an example?
Many thanks!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Lei Hang
- Solved:
- 2020-07-23
- Last query:
- 2020-07-23
- Last reply:
- 2020-07-23
This question was reopened
- 2020-07-22 by Lei Hang
Jan Stránský (honzik) said : | #1 |
> When I run the example in yade
next time please provide more info (where the example comes from, link, ...)
> It reminds me there is no 'octahedron.gts' file
In such case, run the example from original location [1], where the file is placed [2]
cheers
Jan
[1] https:/
[2] https:/
Lei Hang (h-stone) said : | #2 |
Sorry, the link of the script is https:/
Thank you so much!
Anther question is how to create a gts file? I don't understand the numbers in the 'octahedron.gts' file[1]. My final objective is to use this method to create a cylinder to simulate the membrane in the triaxial test. So understanding the meanings of numbers in the the 'octahedron.gts' file[1] maybe can help me know how to create a cylinder.gts file.
Thanks again!
[1]https:/
Jan Stránský (honzik) said : | #3 |
> I don't understand the numbers in the 'octahedron.gts' file
reverse engineering:
> 258 768 512
258 vertices, each line given the coordinates
768 edges, each line indices of connected vertices
512 faces, each line indices of face-forming edges
Example of "bi-tetrahedron":
###
5 9 6
0 0 -1
1 0 0
-1 -1 0
-1 1 0
0 0 2
1 2
1 3
1 4
2 3
3 4
4 2
2 5
3 5
4 5
1 4 2
2 5 3
3 6 1
4 7 8
5 8 9
6 9 7
###
test in yade:
###
import gts
from yade import pack
with open("test.gts") as f:
surf = gts.read(f)
print(surf.
O.bodies.
###
cheers
Jan
Lei Hang (h-stone) said : | #4 |
Hello Jan,
Thank you for your answers! After your explanation, I understand the meanings of the numbers.
1.According to your script, I just mark the vertices and lines by myself and change the indices of lines and faces based on my order. But I am failed to create the same "bi-tetrahedron" as you shown to me. So, is there any rules for creating the "vertices"and the indices of "edges" and "faces"?
2. For the simple geometry, we can create the coordinates of the vertices, the indices of the lines and faces by ourselves. But for complex geometry, it maybe have too many "vertices","edges" and "faces", such as the 'octahedron.gts' file. It has 258 vertices,768 edges and 512 faces. Do we have to write the coordinates of the vertices, the indices of the lines and faces by ourselves? Is there any methods to create them?
Thanks!
The modified numbers are as follows,
###
5 9 6
0 0 -1
1 0 0
-1 -1 0
-1 1 0
0 0 2
1 2
1 3
1 4
2 3
2 4
3 4
2 5
3 5
4 5
1 2 5
1 3 4
2 3 6
5 7 8
4 7 9
6 8 9
###
Jan Stránský (honzik) said : | #5 |
1)
of course there are rules :-)
specifically for faces (where is your problem), the numbers are indices of edges, in counter-clockwise order (seen from the resulting normal direction).
In your case, your first face is
> 1 2 5
your 1st, 2nd and 5th edges are
> 1 2
> 1 3
> 2 4
I.e. you tell gts to create triangle from vertices number 1, 2, 3 and 4, which is the problem.
2)
there are plenty of options.
First, you need the vertices and triangles:
- "by hand" (like the simple example)
- programatically "by hand", e.g. cylinder should be ok to triangulate "manually"
- using some external meshing software
- from existing file (e.g. from STL file format you can convert to GTS using stl2gts utility from libgts-bin Ubuntu package)
Once having the data, you can:
- create the gts file "by hand"
- create the file programatically by yourself
- create the gts structure using gts.Vertex, gts.Edge, gts.Surface and finally gts.Surface.write method [3]
- save it to another format and convert it to gts (e.g. stl2gts)
cheers
Jan
Lei Hang (h-stone) said : | #6 |
I am so sorry, Jan. I don't fully understand these methods you taught me.
Could you show me an example to create a cylinder gts file by the two steps as you taught me?
First step: Getting the vertices and triangles through this method (programatically "by hand", e.g. cylinder should be ok to triangulate "manually")
Second step: Creating the cylinder gts file "by hand" or "programatically by yourself"
I will simulate your process and further understand it.
Very grateful to you!
Jan Stránský (honzik) said : | #7 |
###
import gts
center = (0,0,0)
radius = 1
height = 2
# triangles as yade facets, can be anything else, e.g. custom class
facets = geom.facetCylin
# yade facet to gts.Face
def f2f(f):
p = f.state.pos
o = f.state.ori
vs = [p+o*v for v in f.shape.vertices] # vertices in global coordinates
vs = [gts.Vertex(
es = [gts.Edge(
f = gts.Face(*es) # gts Face
return f
faces = [f2f(f) for f in facets]
# gts Surface
surf = gts.Surface()
for f in faces: # filled with faces
surf.add(f)
print(surf.
surf.cleanup(1e-6) # needs cleanup to merge "almost same vertices"
print(surf.
# save
with open("cyl.gts","w") as f:
surf.write(f)
###
cheers
Jan
Lei Hang (h-stone) said : | #8 |
Thank you for your time and effort!
Lei Hang (h-stone) said : | #9 |
Hi Jan,
After I use yade to run the script you gave me. Why it create an empty cyl.gts file? The running information is as follows:
#
l@ubuntu:~/yade$ yade cyl.py
Welcome to Yade 2020.01a
Using python version: 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0]
TCP python prompt on localhost:9000, auth cookie `ykcuas'
XMLRPC info provider on http://
Running script cyl.py
True False True
True True True
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]
#
Thanks!
Jan Stránský (honzik) said : | #10 |
I have no idea, tested with 2018.02b and 2020-06-
cheers
Jan
Lei Hang (h-stone) said : | #11 |
OK, Thanks a lot!