def make_2d(mesh, dims): print ">>>>>> make_2d" x,y=dims print "X-dim=%s, Y-dim=%s, Z-dim=%s" % (x,y,1) print "--> make_coords" t0=time.time() coords=utils.make_coords(x,y,1) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createVtx" t0=time.time() verts=mesh.createVtx(coords) print " %.1f ms" % ((time.time()-t0)*1000) print "--> make_quadrilateral_vertex_array" t0=time.time() # vert_arr=utils.make_quadrilateral_vertex_array_orig(verts, x, y) # vert_arr=utils.make_quadrilateral_vertex_array_extend(verts, x) vert_arr=utils.make_quadrilateral_vertex_array(verts, x) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createEntArr quadrilaterals" t0=time.time() quads,status=mesh.createEntArr(iMesh.Topology.quadrilateral,vert_arr) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createEntSet(s)" set=mesh.createEntSet(ordered=False) set.add(quads) utils.print_mesh_types(mesh) print "<<<<<<\n"
def make_test_mesh(x,y,z=1): mesh=iMesh.Mesh() # Set the adjacency table such that all intermediate-topologies are generated mesh.adjTable = np.array([[7, 4, 4, 1],[1, 7, 5, 5],[1, 5, 7, 5],[1, 5, 5, 7]], dtype='int32') coords=utils.make_coords(x,y,z) verts=mesh.createVtx(coords) if z is 1: vert_arr=utils.make_quadrilateral_vertex_array(verts, x) ents,status=mesh.createEntArr(iMesh.Topology.quadrilateral, vert_arr) else: vert_arr=utils.make_hexahedron_vertex_array(verts, x, y, z) ents,status=mesh.createEntArr(iMesh.Topology.hexahedron, vert_arr) # Add data to the entities in each cell_dimension for i in range(4): ents=mesh.getEntities(type=i) if len(ents) > 0: tag=mesh.createTag('%s_data' % i,1,np.int32) m=np.prod([10]*(i+1)) dat=np.arange(m,m+len(ents),dtype=np.int32) # print 'start: %s, end: %s' % (m, m+100) # dat=rnd.uniform(m,m+100,len(ents)).astype(np.int32) print dat tag[ents]=dat return mesh
def make_3d(mesh, dims, t3d): print ">>>>>> make_3d" x,y,z=dims print "X-dim=%s, Y-dim=%s, Z-dim=%s" % (x,y,z) print "--> make_coords" t0=time.time() coords=utils.make_coords(x,y,z) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createVtx" t0=time.time() verts=mesh.createVtx(coords) print " %.1f ms" % ((time.time()-t0)*1000) print "--> make_hexahedron_vertex_array" t0=time.time() # vert_arr=utils.make_hexahedron_vertex_array_orig(verts, x,y,z) # vert_arr=utils.make_hexahedron_vertex_array_extend(verts, x,y,z) vert_arr=utils.make_hexahedron_vertex_array(verts, x,y,z) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createEntArr hexahedrons" t0=time.time() cubes,status=mesh.createEntArr(iMesh.Topology.hexahedron,vert_arr) print " %.1f ms" % ((time.time()-t0)*1000) print "--> createEntSet(s)" if t3d: set=mesh.createEntSet(ordered=False) set.add(cubes) else: t0=time.time() slice_size=(x-1)*(y-1) # Add a set for the 'top' (5th face) of each 'layer' in the mesh for zi in range(z-1): set=mesh.createEntSet(ordered=False) # The 5th face (index 4) is always the top set.add([x[4] for x in mesh.getEntAdj(cubes[zi*slice_size:(zi+1)*slice_size], iBase.Type.face)]) # Add a final set for the 'bottom' (6th face) of the last 'layer' in the mesh set=mesh.createEntSet(ordered=False) # The 6th face (index 5) is always the top set.add([x[5] for x in mesh.getEntAdj(cubes[(z-1)*slice_size:z*slice_size], iBase.Type.face)]) print " %.1f ms" % ((time.time()-t0)*1000) utils.print_mesh_types(mesh) print "<<<<<<\n"
x_coords, y_coords = utils.centroid_to_vertex_coords(x_coords=x_coords, y_coords=y_coords) x_cnt=len(x_coords) y_cnt=len(y_coords) coords=[] icoords=[] z=0 for y in range(y_cnt): icoords=[] for x in range(x_cnt): icoords+=[[x_coords[x],y_coords[y],z]] coords+=icoords del icoords # Create the vertices verts=mesh.createVtx(utils.make_coords(x_cnt, y_cnt, z)) nverts=len(verts) # Add the vertices as an EntitySet that is ordered and doesn't contain duplicates # Unnecessary and only complicates structure # vert_set=mesh.createEntSet(ordered=True) # vert_set.add(verts) # Create quadrilateral entities # Build the appropriate vertex-array from the vertices vert_arr = utils.make_quadrilateral_vertex_array(verts=verts, x_cnt=x_cnt) quads,status=mesh.createEntArr(iMesh.Topology.quadrilateral,vert_arr) nquads=len(quads) ## Create Geocoordinate tag geo_tag=mesh.createTag('GEOCOORDINATES',3,numpy.float)