本文整理汇总了Python中yade.utils.facet函数的典型用法代码示例。如果您正苦于以下问题:Python facet函数的具体用法?Python facet怎么用?Python facet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了facet函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: gtsSurface2Facets
def gtsSurface2Facets(surf, **kw):
"""Construct facets from given GTS surface. **kw is passed to utils.facet."""
import gts
return [
utils.facet([v.coords() for v in face.vertices()], **kw)
for face in surf.faces()
]
开发者ID:8803104,项目名称:trunk,代码行数:7,代码来源:pack.py
示例2: iges
def iges(fileName,shift=(0,0,0),scale=1.0,returnConnectivityTable=False,**kw):
""" Import triangular mesh from .igs file, return list of created facets.
:param string fileName: name of iges file
:param (float,float,float)|Vector3 shift: (X,Y,Z) parameter moves the specimen.
:param float scale: factor scales the given data.
:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.utils.facet`
:param bool returnConnectivityTable: if True, apart from facets returns also nodes (list of (x,y,z) nodes coordinates) and elements (list of (id1,id2,id3) element nodes ids). If False (default), returns only facets
"""
nodes,elems = [],[]
f = open(fileName)
for line in f:
if line.startswith('134,'): # read nodes coordinates
ls = line.split(',')
v = Vector3(
float(ls[1])*scale + shift[0],
float(ls[2])*scale + shift[1],
float(ls[3])*scale + shift[2]
)
nodes.append(v)
if line.startswith('136,'): # read elements
ls = line.split(',')
i1,i2,i3 = int(ls[3])/2, int(ls[4])/2, int(ls[5])/2 # the numbering of nodes is 1,3,5,7,..., hence this int(ls[*])/2
elems.append( (i1,i2,i3) )
facets = [utils.facet( ( nodes[e[0]], nodes[e[1]], nodes[e[2]] ), **kw) for e in elems]
if returnConnectivityTable:
return facets, nodes, elems
return facets
开发者ID:YananHe,项目名称:myyade,代码行数:28,代码来源:ymport.py
示例3: facetPolygonHelixGenerator
def facetPolygonHelixGenerator(center,radiusOuter,pitch=0,orientation=Quaternion((0,1,0),0.0),segmentsNumber=10,angleRange=None,radiusInner=0,**kw):
"""
Please, do not use this function directly! Use geom.facetPloygon and geom.facetHelix instead.
This is the base function for generating polygons and helixes from facets.
"""
# check zero dimentions
if (segmentsNumber<3): raise RuntimeError("The segmentsNumber should be at least 3");
if (radiusOuter<=0): raise RuntimeError("The radiusOuter should have the positive value");
if (radiusInner<0): raise RuntimeError("The radiusInner should have the positive value or 0");
if angleRange==None: angleRange=(0,2*math.pi)
anglesInRad = numpy.linspace(angleRange[0], angleRange[1], segmentsNumber+1, endpoint=True)
heightsInRad = numpy.linspace(0, pitch*(abs(angleRange[1]-angleRange[0])/(2.0*math.pi)), segmentsNumber+1, endpoint=True)
POuter=[];
PInner=[];
PCenter=[];
z=0;
for i in anglesInRad:
XOuter=radiusOuter*math.cos(i); YOuter=radiusOuter*math.sin(i);
POuter.append(Vector3(XOuter,YOuter,heightsInRad[z]))
PCenter.append(Vector3(0,0,heightsInRad[z]))
if (radiusInner!=0):
XInner=radiusInner*math.cos(i); YInner=radiusInner*math.sin(i);
PInner.append(Vector3(XInner,YInner,heightsInRad[z]))
z+=1
for i in range(0,len(POuter)):
POuter[i]=orientation*POuter[i]+center
PCenter[i]=orientation*PCenter[i]+center
if (radiusInner!=0):
PInner[i]=orientation*PInner[i]+center
ret=[]
for i in range(1,len(POuter)):
if (radiusInner==0):
ret.append(utils.facet((PCenter[i],POuter[i],POuter[i-1]),**kw))
else:
ret.append(utils.facet((PInner[i-1],POuter[i-1],POuter[i]),**kw))
ret.append(utils.facet((PInner[i],PInner[i-1],POuter[i]),**kw))
return ret
开发者ID:yade,项目名称:trunk,代码行数:42,代码来源:geom.py
示例4: facetSphere
def facetSphere(center,radius,thetaResolution=8,phiResolution=8,returnElementMap=False,**kw):
"""
Create arbitrarily-aligned sphere composed of facets, with given center, radius and orientation.
Return List of facets forming the sphere. Parameters inspired by ParaView sphere glyph
:param Vector3 center: center of the created sphere
:param float radius: sphere radius
:param int thetaResolution: number of facets around "equator"
:param int phiResolution: number of facets between "poles" + 1
:param bool returnElementMap: returns also tuple of nodes ((x1,y1,z1),(x2,y2,z2),...) and elements ((id01,id02,id03),(id11,id12,id13),...) if true, only facets otherwise
:param \*\*kw: (unused keyword arguments) passed to utils.facet;
"""
# check zero dimentions
if (radius<=0): raise RuntimeError("The radius should have the positive value");
if (thetaResolution<3): raise RuntimeError("thetaResolution must be > 3");
if (phiResolution<3): raise RuntimeError("phiResolution must be > 3");
r,c0,c1,c2 = radius,center[0],center[1],center[2]
nodes = [Vector3(c0,c1,c2+radius)]
phis = numpy.linspace(math.pi/(phiResolution-1),math.pi,phiResolution-2,endpoint=False)
thetas = numpy.linspace(0,2*math.pi,thetaResolution,endpoint=False)
nodes.extend((Vector3(c0+r*math.cos(theta)*math.sin(phi),c1+r*math.sin(theta)*math.sin(phi),c2+r*math.cos(phi)) for phi in phis for theta in thetas))
nodes.append(Vector3(c0,c1,c2-radius))
n = len(nodes)-1
elements = [(0,i+1,i+2) for i in range(thetaResolution-1)]
elements.append((0,1,thetaResolution))
for j in range(0,phiResolution-3):
k = j*thetaResolution + 1
elements.extend((k+i,k+i+1,k+i+thetaResolution) for i in range(thetaResolution-1))
elements.append((k,k+thetaResolution-1,k+2*thetaResolution-1))
elements.extend((k+i+thetaResolution,k+i+1+thetaResolution,k+i+1) for i in range(thetaResolution-1))
elements.append((k+2*thetaResolution-1,k+thetaResolution,k))
elements.extend((n,n-i-1,n-i-2) for i in range(thetaResolution-1))
elements.append((n,n-1,n-thetaResolution))
facets = [utils.facet(tuple(nodes[node] for node in elem),**kw) for elem in elements]
if returnElementMap:
return facets,nodes,elements
return facets
开发者ID:yade,项目名称:trunk,代码行数:40,代码来源:geom.py
示例5: createFacets
def createFacets(self,**kw):
self.facets = [utils.facet(tuple(self.nodes[i] for i in e),**kw) for e in self.elements]
开发者ID:YananHe,项目名称:myyade,代码行数:2,代码来源:ymport.py
示例6: gmsh
def gmsh(meshfile="file.mesh",shift=Vector3.Zero,scale=1.0,orientation=Quaternion((0,1,0),0.0),**kw):
""" Imports geometry from .mesh file and creates facets.
:Parameters:
`shift`: [float,float,float]
[X,Y,Z] parameter moves the specimen.
`scale`: float
factor scales the given data.
`orientation`: quaternion
orientation of the imported mesh
`**kw`: (unused keyword arguments)
is passed to :yref:`yade.utils.facet`
:Returns: list of facets forming the specimen.
mesh files can easily be created with `GMSH <http://www.geuz.org/gmsh/>`_.
Example added to :ysrc:`examples/packs/packs.py`
Additional examples of mesh-files can be downloaded from
http://www-roc.inria.fr/gamma/download/download.php
"""
infile = open(meshfile,"r")
lines = infile.readlines()
infile.close()
nodelistVector3=[]
elementlistVector3=[] # for deformable elements
findVerticesString=0
while (lines[findVerticesString].split()[0]<>'Vertices'): #Find the string with the number of Vertices
findVerticesString+=1
findVerticesString+=1
numNodes = int(lines[findVerticesString].split()[0])
for i in range(numNodes):
nodelistVector3.append(Vector3(0.0,0.0,0.0))
id = 0
for line in lines[findVerticesString+1:numNodes+findVerticesString+1]:
data = line.split()
nodelistVector3[id] = orientation*Vector3(float(data[0])*scale,float(data[1])*scale,float(data[2])*scale)+shift
id += 1
findTriangleString=findVerticesString+numNodes
while (lines[findTriangleString].split()[0]<>'Triangles'): #Find the string with the number of Triangles
findTriangleString+=1
findTriangleString+=1
numTriangles = int(lines[findTriangleString].split()[0])
triList = []
for i in range(numTriangles):
triList.append([0,0,0,0])
tid = 0
for line in lines[findTriangleString+1:findTriangleString+numTriangles+1]:
data = line.split()
id1 = int(data[0])-1
id2 = int(data[1])-1
id3 = int(data[2])-1
triList[tid][0] = tid
triList[tid][1] = id1
triList[tid][2] = id2
triList[tid][3] = id3
tid += 1
ret=[]
for i in triList:
a=nodelistVector3[i[1]]
b=nodelistVector3[i[2]]
c=nodelistVector3[i[3]]
ret.append(utils.facet((nodelistVector3[i[1]],nodelistVector3[i[2]],nodelistVector3[i[3]]),**kw))
return ret
开发者ID:YananHe,项目名称:myyade,代码行数:70,代码来源:ymport.py
示例7: unv
def unv(fileName,shift=(0,0,0),scale=1.0,**kw):
""" Import geometry from unv file, return list of created facets.
:Parameters:
`fileName`: string
name of unv file
`shift`: [float,float,float] | Vector3
[X,Y,Z] parameter moves the specimen.
`scale`: float
factor scales the given data.
`**kw`: (unused keyword arguments)
is passed to :yref:`yade.utils.facet`
unv files are mainly used for FEM analyses (are used by `OOFEM <http://www.oofem.org/>` and `Abakus <http://www.simulia.com/products/abaqus_fea.html>`), but triangular elements can be imported as facets.
These files cen be created e.g. with open-source free software `Salome <salome-platform.org>`.
Example: :ysrc:`scripts/test/unvRead.py`."""
class UNVReader:
# class used in ymport.unv function
# reads and evaluate given unv file and extracts all triangles
# can be extended to read tetrahedrons as well
def __init__(self,fileName,shift=(0,0,0),scale=1.0):
self.shift = shift
self.scale = scale
self.unvFile = open(fileName,'r')
self.flag = 0
self.line = self.unvFile.readline()
self.lineSplit = self.line.split()
self.vertices = []
self.verticesTris = []
self.read()
def readLine(self):
self.line = self.unvFile.readline()
self.lineSplit = self.line.split()
def read(self):
while self.line:
self.evalLine()
self.line = self.unvFile.readline()
self.unvFile.close()
def evalLine(self):
self.lineSplit = self.line.split()
if len(self.lineSplit) <= 1: # eval special unv format
if self.lineSplit[0] == '-1': pass
elif self.lineSplit[0] == '2411': self.flag = 1; # nodes
elif self.lineSplit[0] == '2412': self.flag = 2; # edges (lines)
else: self.flag = 4; # volume elements or other, not interesting for us
elif self.flag == 1: self.evalVertices()
elif self.flag == 2: self.evalEdge()
elif self.flag == 3: self.evalFacet()
#elif self.flag == 4: self.evalGroup()
def evalVertices(self):
self.readLine()
self.vertices.append((
self.shift[0]+self.scale*float(self.lineSplit[0]),
self.shift[1]+self.scale*float(self.lineSplit[1]),
self.shift[2]+self.scale*float(self.lineSplit[2])))
def evalEdge(self):
if self.lineSplit[1]=='41': self.flag = 3; self.evalFacet()
else: self.readLine(); self.readLine()
def evalFacet(self):
if self.lineSplit[1]=='41': # triangle
self.readLine()
self.verticesTris.append([
self.vertices[int(self.lineSplit[0])-1],
self.vertices[int(self.lineSplit[1])-1],
self.vertices[int(self.lineSplit[2])-1]])
else: # is not triangle
self.readLine()
self.flag = 4
# can be added function to handle tetrahedrons
unvReader = UNVReader(fileName,shift,scale,**kw)
return [utils.facet(tri,**kw) for tri in unvReader.verticesTris]
开发者ID:hohiroki,项目名称:trunk,代码行数:74,代码来源:ymport.py
示例8: ForceResetter
from yade import utils
## PhysicalParameters
Young = 7e6
Poisson = 0.2
Density = 2700
# Append a material
mat = O.materials.append(FrictMat(young=Young, poisson=Poisson, density=Density, frictionAngle=26))
O.bodies.append(
[
utils.sphere([0, 0, 0.6], 0.25, material=mat),
utils.facet(
[[-0.707, -0.707, 0.1], [0, 1.414, 0], [1.414, 0, 0]], dynamic=False, color=[1, 0, 0], material=mat
),
utils.facet([[0, 1.414, 0], [1.414, 0, 0], [0.707, 0.707, -2.0]], dynamic=False, color=[1, 0, 0], material=mat),
]
)
## Engines
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
[Ig2_Facet_Sphere_ScGeom()], [Ip2_FrictMat_FrictMat_FrictPhys()], [Law2_ScGeom_FrictPhys_CundallStrack()]
),
NewtonIntegrator(damping=0.3, gravity=(0, 0, -10)),
]
开发者ID:kelaogui,项目名称:trunk,代码行数:29,代码来源:test-sphere-facet-corner.py
示例9: doWall
def doWall(a,b,c,d):
return [utils.facet((a,b,c),**kw),utils.facet((a,c,d),**kw)]
开发者ID:yade,项目名称:trunk,代码行数:2,代码来源:geom.py
示例10: facetCylinderConeGenerator
def facetCylinderConeGenerator(center,radiusTop,height,orientation=Quaternion((0,1,0),0.0),
segmentsNumber=10,wallMask=7,angleRange=None,closeGap=False,
radiusBottom=-1,
radiusTopInner=-1,
radiusBottomInner=-1,
**kw):
"""
Please, do not use this function directly! Use geom.facetCylinder and geom.facetCone instead.
This is the base function for generating cylinders and cones from facets.
:param float radiusTop: top radius
:param float radiusBottom: bottom radius
:param \*\*kw: (unused keyword arguments) passed to utils.facet;
"""
#For cylinders top and bottom radii are equal
if (radiusBottom == -1):
radiusBottom = radiusTop
if ((radiusTopInner > 0 and radiusTopInner > radiusTop) or (radiusBottomInner > 0 and radiusBottomInner > radiusBottom)):
raise RuntimeError("The internal radius cannot be larger than outer");
# check zero dimentions
if (segmentsNumber<3): raise RuntimeError("The segmentsNumber should be at least 3");
if (height<0): raise RuntimeError("The height should have the positive value");
if angleRange==None: angleRange=(0,2*math.pi)
if (abs(angleRange[1]-angleRange[0])>2.0*math.pi): raise RuntimeError("The |angleRange| cannot be larger 2.0*math.pi");
if (angleRange[1]<angleRange[0]): raise RuntimeError("angleRange[1] should be larger or equal angleRange[1]");
if isinstance(angleRange,float):
print(u'WARNING: geom.facetCylinder,angleRange should be (Θmin,Θmax), not just Θmax (one number), update your code.')
angleRange=(0,angleRange)
anglesInRad = numpy.linspace(angleRange[0], angleRange[1], segmentsNumber+1, endpoint=True)
PTop=[]; PTop.append(Vector3(0,0,+height/2))
PTopIn=[]; PTopIn.append(Vector3(0,0,+height/2))
PBottom=[]; PBottom.append(Vector3(0,0,-height/2))
PBottomIn=[]; PBottomIn.append(Vector3(0,0,-height/2))
for i in anglesInRad:
XTop=radiusTop*math.cos(i); YTop=radiusTop*math.sin(i);
PTop.append(Vector3(XTop,YTop,+height/2))
if (radiusTopInner > 0):
XTopIn=radiusTopInner*math.cos(i); YTopIn=radiusTopInner*math.sin(i);
PTopIn.append(Vector3(XTopIn,YTopIn,+height/2))
XBottom=radiusBottom*math.cos(i); YBottom=radiusBottom*math.sin(i);
PBottom.append(Vector3(XBottom,YBottom,-height/2))
if (radiusBottomInner > 0):
XBottomIn=radiusBottomInner*math.cos(i); YBottomIn=radiusBottomInner*math.sin(i);
PBottomIn.append(Vector3(XBottomIn,YBottomIn,-height/2))
for i in range(0,len(PTop)):
PTop[i]=orientation*PTop[i]+center
PBottom[i]=orientation*PBottom[i]+center
if (len(PTopIn)>1):
PTopIn[i]=orientation*PTopIn[i]+center
if (len(PBottomIn)>1):
PBottomIn[i]=orientation*PBottomIn[i]+center
ret=[]
for i in range(2,len(PTop)):
if (wallMask&1)and(radiusTop!=0):
if (len(PTopIn)>1):
ret.append(utils.facet((PTop[i-1],PTopIn[i],PTopIn[i-1]),**kw))
ret.append(utils.facet((PTop[i-1],PTop[i],PTopIn[i]),**kw))
else:
ret.append(utils.facet((PTop[0],PTop[i],PTop[i-1]),**kw))
if (wallMask&2)and(radiusBottom!=0):
if (len(PBottomIn)>1):
ret.append(utils.facet((PBottom[i-1],PBottomIn[i],PBottomIn[i-1]),**kw))
ret.append(utils.facet((PBottom[i-1],PBottom[i],PBottomIn[i]),**kw))
else:
ret.append(utils.facet((PBottom[0],PBottom[i-1],PBottom[i]),**kw))
if wallMask&4:
if (radiusBottom!=0):
ret.append(utils.facet((PTop[i],PBottom[i],PBottom[i-1]),**kw))
if (radiusTop!=0):
ret.append(utils.facet((PBottom[i-1],PTop[i-1],PTop[i]),**kw))
if (closeGap):
if (wallMask&1)and(radiusTop!=0)and(abs(((angleRange[1]-angleRange[0])) > math.pi)):
pts=[(radiusTop*math.cos(angleRange[i]),radiusTop*math.sin(angleRange[i])) for i in (0,1)]
pp=[(pts[0][0],pts[0][1],+height/2.0), (pts[1][0],pts[1][1],+height/2.0), (0,0,+height/2.0)]
pp=[orientation*p+center for p in pp]
ret.append(utils.facet(pp,**kw))
if (wallMask&2)and(radiusBottom!=0)and(abs(((angleRange[1]-angleRange[0])) > math.pi)):
pts=[(radiusBottom*math.cos(angleRange[i]),radiusBottom*math.sin(angleRange[i])) for i in (0,1)]
pp=[(0,0,-height/2.0), (pts[1][0],pts[1][1],-height/2.0), (pts[0][0],pts[0][1],-height/2.0)]
pp=[orientation*p+center for p in pp]
ret.append(utils.facet(pp,**kw))
if (wallMask&4):
ptsBottom=[(radiusBottom*math.cos(angleRange[i]),radiusBottom*math.sin(angleRange[i])) for i in (0,1)]
ptsTop=[(radiusTop*math.cos(angleRange[i]),radiusTop*math.sin(angleRange[i])) for i in (0,1)]
if (abs(((angleRange[1]-angleRange[0])) >= math.pi)):
#.........这里部分代码省略.........
开发者ID:yade,项目名称:trunk,代码行数:101,代码来源:geom.py
示例11:
from yade import *
from yade import utils,export
O.bodies.append([
utils.sphere((0,0,0),1),
utils.sphere((0,2,0),1),
utils.sphere((0,2,3),2),
utils.facet([Vector3(0,-3,-1),Vector3(0,-2,5),Vector3(5,4,0)]),
utils.facet([Vector3(0,-3,-1),Vector3(0,-2,5),Vector3(-5,4,0)])
])
vtkExporter = export.VTKExporter('vtkExporterTesting')
vtkExporter.exportSpheres(what=[('dist','b.state.pos.norm()')])
vtkExporter.exportFacets(what=[('pos','b.state.pos')])
开发者ID:8803104,项目名称:trunk,代码行数:14,代码来源:vtkExporter.py
示例12: ForceResetter
##
from math import *
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Box_Aabb(), Bo1_Facet_Aabb()]),
IGeomDispatcher([Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()]),
IPhysDispatcher([Ip2_FrictMat_FrictMat_FrictPhys()]),
ElasticContactLaw(),
RotationEngine(ids=[1], rotationAxis=[1, 0, 0], angularVelocity=0.01),
NewtonIntegrator(damping=0.2),
]
from yade import utils
scale = 0.1
O.bodies.append(utils.facet([[scale, 0, 0], [-scale, -scale, 0], [-scale, scale, 0]], fixed=True, color=[1, 0, 0]))
O.bodies.append(utils.sphere([0, 0, 0.99 * scale], 1 * scale, color=[0, 1, 0], wire=True, fixed=True))
O.dt = 0.4 * utils.PWaveTimeStep()
from yade import qt
qt.View()
renderer = qt.Renderer()
renderer.intrGeom = True
qt.Controller()
O.step()
O.step()
O.step()
O.run(20000)
开发者ID:klausthoeni,项目名称:trunk,代码行数:30,代码来源:exact-rot-facet.py
注:本文中的yade.utils.facet函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论