← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4045: modification of utils.UnstructuredMesh, added utils.polyhedron

 

------------------------------------------------------------
revno: 4045
committer: Jan Stransky <jan.stransky@xxxxxxxxxxx>
timestamp: Tue 2014-07-01 07:36:28 +0200
message:
  modification of utils.UnstructuredMesh, added utils.polyhedron
modified:
  py/utils.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'py/utils.py'
--- py/utils.py	2014-02-12 13:18:59 +0000
+++ py/utils.py	2014-07-01 05:36:28 +0000
@@ -348,7 +348,7 @@
 	b.chain=chain
 	return b
 
-def tetraPoly(vertices,strictCheck=True,dynamic=True,fixed=False,wire=True,color=None,highlight=False,noBound=False,material=-1,mask=1,chain=-1):
+def tetraPoly(vertices,dynamic=True,fixed=False,wire=True,color=None,highlight=False,noBound=False,material=-1,mask=1,chain=-1):
 	"""Create tetrahedron (actually simple Polyhedra) with given parameters.
 
 	:param [Vector3,Vector3,Vector3,Vector3] vertices: coordinates of vertices in the global coordinate system.
@@ -360,7 +360,7 @@
 	inertia = b.shape.GetInertia()
 	center = b.shape.GetCentroid()
 	_commonBodySetup(b,volume,inertia,material,noBound=noBound,pos=center,fixed=fixed)
-	b.aspherical=False # mass and inertia are 0 anyway; fell free to change to ``True`` if needed
+	b.aspherical=False
 	b.state.ori = b.shape.GetOri()
 	b.mask=mask
 	b.chain=chain
@@ -394,6 +394,24 @@
 	b.chain = chain
 	return b
 
+def polyhedron(vertices,dynamic=True,fixed=False,wire=True,color=None,highlight=False,noBound=False,material=-1,mask=1,chain=-1):
+	"""Create tetrahedron (actually simple Polyhedra) with given parameters.
+
+	:param [Vector3,Vector3,Vector3,Vector3] vertices: coordinates of vertices in the global coordinate system.
+
+	See :yref:`yade.utils.sphere`'s documentation for meaning of other parameters."""
+	b=Body()
+	b.shape = Polyhedra(v=vertices,color=color if color else randomColor(),wire=wire,highlight=highlight)
+	volume = b.shape.GetVolume()
+	inertia = b.shape.GetInertia()
+	center = b.shape.GetCentroid()
+	_commonBodySetup(b,volume,inertia,material,noBound=noBound,pos=center,fixed=fixed)
+	b.aspherical=False
+	b.state.ori = b.shape.GetOri()
+	b.mask=mask
+	b.chain=chain
+	return b
+
 
 
 
@@ -1013,6 +1031,7 @@
 				b = facet([self.vertices[j] for j in c],**kw)
 			elif len(c) == 4:
 				b = tetra([self.vertices[j] for j in c],**kw)
+				#b = polyhedron([self.vertices[j] for j in c],**kw)
 			else:
 				raise RuntimeError, "Unsupported cell shape (should be triangle or tetrahedron)"
 			self.elements[i] = b
@@ -1050,6 +1069,8 @@
 					self.forces[ie[1]] += f*w1/ww
 					self.forces[ie[2]] += f*w2/ww
 					self.forces[ie[3]] += f*w3/ww
+				else:
+					raise RuntimeError, "TODO"
 		return self.forces
 	def setPositionsOfNodes(self,newPoss):
 		"""Sets new position of nodes and also updates all elements in the simulation
@@ -1070,6 +1091,8 @@
 				e.shape.vertices = [self.vertices[j] for j in c]
 			elif isinstance(e.shape,Tetra):
 				e.shape.v = [self.vertices[j] for j in c]
+			else:
+				raise RuntimeError, "TODO"
 	def toSimulation(self,bodies=None):
 		"""Insert all elements to Yade simulation
 		"""