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=[] for z in range(z_cnt): for y in range(y_cnt): for x in range(x_cnt): coords+=[[x_coords[x],y_coords[y],z_coords[z]]] # Create the vertices verts=mesh.createVtx(coords) nverts=len(verts) # Build the appropriate vertex-array from the vertices vert_arr = utils.make_hexahedron_vertex_array(verts=verts, x_cnt=x_cnt, y_cnt=y_cnt, z_cnt=z_cnt) cubes,status=mesh.createEntArr(iMesh.Topology.hexahedron,vert_arr) nquads=len(cubes) slice_size=(x_cnt-1)*(y_cnt-1) # Add a set for the 'top' (5th face) of each 'layer' in the mesh for zi in range(z_cnt-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_cnt-1)*slice_size:z_cnt*slice_size], iBase.Type.face)]) ## Create tags for each data_variable
if num == 1: print "X-dim=%s, Y-dim=%s, Z-dim=%s" % (2, 2, 2) coords = make_coords(2, 2, 2) # coords=[[0,0,0], #0 # [1,0,0], #1 # [0,1,0], #2 # [1,1,0], #3 # [0,0,1], #4 # [1,0,1], #5 # [0,1,1], #6 # [1,1,1]] #7 # Create the vertices verts = mesh.createVtx(coords) vert_arr = utils.make_hexahedron_vertex_array(verts, 2, 2, 2) # # Build the appropriate vertex-array from the vertices # vert_arr=[verts[0],verts[1],verts[3],verts[2],verts[4],verts[5],verts[7],verts[6]] elif num == 2: print "X-dim=%s, Y-dim=%s, Z-dim=%s" % (3, 2, 2) coords = make_coords(3, 2, 2) # coords=[[0,0,0], # [1,0,0], # [2,0,0], # [0,1,0], # [1,1,0], # [2,1,0], # [0,0,1], # [1,0,1], # [2,0,1],