Exemplo n.º 1
0
    def _New_Initialization(self):
        """Initialization(self)
        Run important initialization steps important for the
        class to work.

        self.vertices contains x,y,z coordinates of vertices. shape = self.n_vertices,3
        self.faces contains indices of vertices forming faces. shape = self.n_faces,3
        self.assoc contains indices of faces associated to a vertice. shape = self.n_vertices,6
            Note: when only 5 faces associated, 6th value is equal to -99
        """
        print("Generating the geodesic surface using PyGTS")
        try:
            import gts
        except:
            print(
                "You likely don't have the PyGTS package installed on your computer."
            )
            print(
                "It is impossible to create the surface vertices from scratch."
            )
            print("Will trying reading them from the restart file instead.")
            self._Read_geodesic()
            return
        # Generate the geodesic primitives
        s = gts.sphere(self.ndiv)
        x, y, z, t = gts.get_coords_and_face_indices(s, True)
        self.vertices = np.c_[x, y, z]
        self.faces = np.array(t)
        self.n_vertices = self.vertices.shape[0]
        self.n_faces = self.faces.shape[0]
        print("Calculatating the associations")
        self.assoc = Utils.Tessellation.Match_assoc(self.faces,
                                                    self.n_vertices)

        # We will pre-calculate the surface areas. They will need to be multiplied by rc^2.
        # The calculation is simply the Pythagorean sum of the areas of the respective projections on the x,y,z planes.
        print("meshing the surface")
        mesh = self.vertices[self.faces]
        print("calculating the area")
        self.pre_area = 0.5 * np.sqrt(
            ((mesh[:, 0, 0] * mesh[:, 1, 1] + mesh[:, 1, 0] * mesh[:, 2, 1] +
              mesh[:, 2, 0] * mesh[:, 0, 1]) -
             (mesh[:, 0, 1] * mesh[:, 1, 0] + mesh[:, 1, 1] * mesh[:, 2, 0] +
              mesh[:, 2, 1] * mesh[:, 0, 0]))**2 +
            ((mesh[:, 0, 1] * mesh[:, 1, 2] + mesh[:, 1, 1] * mesh[:, 2, 2] +
              mesh[:, 2, 1] * mesh[:, 0, 2]) -
             (mesh[:, 0, 2] * mesh[:, 1, 1] + mesh[:, 1, 2] * mesh[:, 2, 1] +
              mesh[:, 2, 2] * mesh[:, 0, 1]))**2 +
            ((mesh[:, 0, 2] * mesh[:, 1, 0] + mesh[:, 1, 2] * mesh[:, 2, 0] +
              mesh[:, 2, 2] * mesh[:, 0, 0]) -
             (mesh[:, 0, 0] * mesh[:, 1, 2] + mesh[:, 1, 0] * mesh[:, 2, 2] +
              mesh[:, 2, 0] * mesh[:, 0, 2]))**2)
        # The cosine of x,y,z for the center of the faces. shape = n_faces, 3
        print("calculating the angles")
        self.cosx, self.cosy, self.cosz = mesh.mean(axis=1).T
        return
Exemplo n.º 2
0
    def __init__(self, radius=1, lod=1):
        Surface.__init__(self)
        self.type = 'Sphere'

        self.radius = radius
        self.lod = lod

        s = gts.sphere(lod)
        s.scale(radius, radius, radius)
        self._obj = s
Exemplo n.º 3
0
 def _New_Initialization(self):
     """Initialization(self)
     Run important initialization steps important for the
     class to work.
     
     self.vertices contains x,y,z coordinates of vertices. shape = self.n_vertices,3
     self.faces contains indices of vertices forming faces. shape = self.n_faces,3
     self.assoc contains indices of faces associated to a vertice. shape = self.n_vertices,6
         Note: when only 5 faces associated, 6th value is equal to -99
     """
     print( "Generating the geodesic surface using PyGTS" )
     try:
         import gts
     except:
         print( "You likely don't have the PyGTS package installed on your computer." )
         print( "It is impossible to create the surface vertices from scratch." )
         print( "Will trying reading them from the restart file instead." )
         self._Read_geodesic()
         return
     # Generate the geodesic primitives
     s = gts.sphere(self.ndiv)
     x,y,z,t = gts.get_coords_and_face_indices(s,True)
     self.vertices = np.c_[x,y,z]
     self.faces = np.array(t)
     self.n_vertices = self.vertices.shape[0]
     self.n_faces = self.faces.shape[0]
     print( "Calculatating the associations" )
     self.assoc = Utils.Tessellation.Match_assoc(self.faces, self.n_vertices)
     
     # We will pre-calculate the surface areas. They will need to be multiplied by rc^2.
     # The calculation is simply the Pythagorean sum of the areas of the respective projections on the x,y,z planes.
     print( "meshing the surface" )
     mesh = self.vertices[self.faces]
     print( "calculating the area" )
     self.pre_area = 0.5 *np.sqrt( ((mesh[:,0,0]*mesh[:,1,1]+mesh[:,1,0]*mesh[:,2,1]+mesh[:,2,0]*mesh[:,0,1]) - (mesh[:,0,1]*mesh[:,1,0]+mesh[:,1,1]*mesh[:,2,0]+mesh[:,2,1]*mesh[:,0,0]))**2 + ((mesh[:,0,1]*mesh[:,1,2]+mesh[:,1,1]*mesh[:,2,2]+mesh[:,2,1]*mesh[:,0,2]) - (mesh[:,0,2]*mesh[:,1,1]+mesh[:,1,2]*mesh[:,2,1]+mesh[:,2,2]*mesh[:,0,1]))**2 + ((mesh[:,0,2]*mesh[:,1,0]+mesh[:,1,2]*mesh[:,2,0]+mesh[:,2,2]*mesh[:,0,0]) - (mesh[:,0,0]*mesh[:,1,2]+mesh[:,1,0]*mesh[:,2,2]+mesh[:,2,0]*mesh[:,0,2]))**2 )
     # The cosine of x,y,z for the center of the faces. shape = n_faces, 3
     print( "calculating the angles" )
     self.cosx, self.cosy, self.cosz = mesh.mean(axis=1).T
     return
Exemplo n.º 4
0
import gts
import woo.pack, woo.dem, woo.log, woo.core
from minieigen import *
woo.master.usesApi = 10101
S = woo.master.scene = woo.core.Scene(fields=[woo.dem.DemField()])
surf = gts.sphere(4)
surf.translate(1.2, 1.2, 1.2)
S.dem.par.add(woo.pack.gtsSurface2Facets(surf),
              nodes=True)  # force adding nodes, for integration
S.periodic = True
S.cell.setBox(2.4, 2.4, 2.4)
S.cell.nextGradV = Matrix3(0., .1, .1, -.1, 0, .1, .1, -.1, -.01)
woo.log.setLevel('MeshVolume', woo.log.TRACE)
S.engines = [
    woo.dem.MeshVolume(stepPeriod=1, label='meshVolume'),
    woo.dem.Leapfrog(reset=True),
    woo.core.PyRunner(
        1,
        'S.plot.addData(i=S.step,V=S.lab.meshVolume.vol,Vcell=S.cell.volume,ratio=S.lab.meshVolume.vol/S.cell.volume)'
    ),
]
S.dt = 1e-4
S.plot.plots = {'i': ('V', 'Vcell', None, 'ratio')}
S.one()
print 'Sphere volume is ', S.lab.meshVolume.vol
S.saveTmp()
Exemplo n.º 5
0
import gts
import woo.pack,woo.dem,woo.log,woo.core
from minieigen import *
woo.master.usesApi=10101
S=woo.master.scene=woo.core.Scene(fields=[woo.dem.DemField()])
surf=gts.sphere(4)
surf.translate(1.2,1.2,1.2)
S.dem.par.add(woo.pack.gtsSurface2Facets(surf),nodes=True) # force adding nodes, for integration
S.periodic=True
S.cell.setBox(2.4,2.4,2.4)
S.cell.nextGradV=Matrix3(0.,.1,.1, -.1,0,.1, .1,-.1,-.01)
woo.log.setLevel('MeshVolume',woo.log.TRACE)
S.engines=[
	woo.dem.MeshVolume(stepPeriod=1,label='meshVolume'),
	woo.dem.Leapfrog(reset=True),
	woo.core.PyRunner(1,'S.plot.addData(i=S.step,V=S.lab.meshVolume.vol,Vcell=S.cell.volume,ratio=S.lab.meshVolume.vol/S.cell.volume)'),
]
S.dt=1e-4
S.plot.plots={'i':('V','Vcell',None,'ratio')}
S.one()
print 'Sphere volume is ',S.lab.meshVolume.vol
S.saveTmp()
    fin_pos.append(list(np.dot(F, np.array(ini_pos[i], float))))
E = 0.5 * (np.dot(F.T, F) - np.eye(3))
datf = open("TestStrains.dat", 'w')
datf.write("The exact strain tensor for the ECM:\n")
datf.write("%1.4f\t%1.4f\t%1.4f\n" % (E[0, 0], E[0, 1], E[0, 2]))
datf.write("%1.4f\t%1.4f\t%1.4f\n" % (E[1, 0], E[1, 1], E[1, 2]))
datf.write("%1.4f\t%1.4f\t%1.4f\n" % (E[2, 0], E[2, 1], E[2, 2]))
for i in xrange(6):
    a = np.trace(F) / 3.
    while True:
        ldil = random.uniform(0.2, 1.5)
        ldev = random.uniform(0.01, 1.5)
        nF = ldil * a * np.eye(3) + ldev * (F - a * np.eye(3))
        if np.linalg.det(nF) > 0.1:
            break
    cell = gts.sphere(4)
    scalex = random.uniform(3, 5)
    scaley = random.uniform(3, 5)
    scalez = random.uniform(.8, 1.5)
    cell.scale(dx=scalex, dy=scaley, dz=scalez)
    cell.translate(dx=ini_pos[i][0], dy=ini_pos[i][1], dz=ini_pos[i][2])
    fname = "MechVerification/Material/cell%02d" % i
    fid = open(fname + '.gts', 'w')
    cell.write(fid)
    fid.close()
    subprocess.call("gts2stl < " + fname + ".gts > " + fname + ".stl",
                    shell=True)

    cell = gts.sphere(4)
    cell.scale(dx=scalex, dy=scaley, dz=scalez)
    for v in cell.vertices():
Exemplo n.º 7
0
triBit=DemField.defaultHighestBit<<1
cylBit=triBit<<1
triMask=DemField.defaultStaticMask|triBit
cylMask=DemField.defaultMovableMask|cylBit

S.dem.par.add([
    Wall.make(-2,axis=2,sense=0,mat=mat,glAB=((-5,-1),(12,8))),
    Facet.make([(-2,-2,0),(2,0,0),(0,2,0)],halfThick=.9,mat=mat,fixed=True,wire=True),
    InfCylinder.make((0,-2,-.5),radius=1.,axis=0,mat=mat,angVel=(1,0,0),mask=cylMask),
    InfCylinder.make((5,0,0),radius=1.5,axis=1,glAB=(-3,5),mat=mat,angVel=(0,.5,0),mask=cylMask),
    Sphere.make((5,4,3),1.,mat=mat),
    Capsule.make((8,6,1),radius=.8,shaft=2,ori=Quaternion(1,(0,.1,1)),mat=mat),
    Ellipsoid.make((0,6,1),semiAxes=(1.1,1.7,.9),ori=Quaternion(1,(.4,.4,1)),mat=mat)
],nodes=True)

surf=gts.sphere(3)
surf.scale(5.,5.,5.)
surf.translate(0,0,4)
S.dem.par.add(woo.pack.gtsSurface2Facets(surf,mask=triMask))

ex=POVRayExport(out='/tmp/pp0',stepPeriod=10,initRun=True,wallTexture='wall',cylCapTexture='flat')
ex.masks=[triBit,cylBit]+ex.masks
ex.textures=["tri","cyl"]+ex.textures

S.engines=DemField.minimalEngines(damping=.2)+[ex]

S.saveTmp()
S.one()
S.run(2000,wait=True)
import subprocess, os.path
subprocess.call(['povray','+W1500','+H1000','+P',ex.out+"_master.pov"],cwd=os.path.dirname(ex.out))