def GrainCreate(vertices, LZ=10): import cubit ### Create a grain from a vertex list ### ### Create the vertices vert_ID = [] for X in vertices: cubit.cmd("create vertex X %f Y %f Z %f" % (X[0], X[1], -LZ / 2.0)) vert_ID.append(cubit.get_last_id("vertex")) ### ### Create the edges curv_ID = [] for i in range(len(vert_ID) - 1): cubit.cmd("create curve vertex %i vertex %i" % (vert_ID[i], vert_ID[i + 1])) curv_ID.append(cubit.get_last_id("curve")) cubit.cmd("create curve vertex %i vertex %i" % (vert_ID[-1], vert_ID[0])) curv_ID.append(cubit.get_last_id("curve")) ### ### Create the surface cmd = "create surface curve" for edge in curv_ID: cmd += " %i" % edge cubit.cmd(cmd) surf_ID = cubit.get_last_id("surface") cubit.cmd("sweep surface %i direction Z distance %f" % (surf_ID, LZ)) grain_ID = cubit.get_last_id("volume") return grain_ID
def BoxCrystalCreate(l, ngrains): import cubit cubit.cmd("create brick X %f" % l) BOX_3D = cubit.get_last_id("volume") ### BB = [-2 * l, 2 * l, -2 * l, 2 * l] rect = [-l / 2., l / 2., -l / 2., l / 2.] sites = SitesGenRect2D(ngrains, rect, BB) (vertices, cells) = VoronoiGen(sites) realcells = VoronoiRemoveInfiniteCells(cells) newsites = SitesSmootherBox(sites, vertices, cells, rect) (newvertices, newcells) = VoronoiGen(newsites) newrealcells = VoronoiRemoveInfiniteCells(newcells) ### ### chop grains ### GRAINS_3D = [] numgrains = 0 for i in range(len(newrealcells)): tmpgrain = GrainCreate(newvertices[newrealcells[i], :], l) cubit.cmd("volume %i copy" % BOX_3D) tmpBOX = cubit.get_last_id("volume") cubit.cmd("intersect volume %i %i keep" % (tmpBOX, tmpgrain)) offset = cubit.get_last_id("volume") if offset > tmpBOX: GRAINS_3D.append([]) for j in range(tmpBOX, offset): GRAINS_3D[numgrains].append(j + 1) cubit.cmd("delete volume %i %i" % (tmpgrain, tmpBOX)) GroupAddVolList("Grain%i" % (numgrains + 1), GRAINS_3D[numgrains]) numgrains += 1 cubit.cmd("delete volume %i" % BOX_3D) return GRAINS_3D
def Layer(Body_IDs, BB, Alpha, Theta1, Theta2, Xoffset=.5): import cubit import numpy as np ### ### Body_ID: a single volume ID ### BB: bounding box in the form [xmin, xmax, ymin, ymax, zmin, zmax] ### Alpha: lamination angle ### Theta1: thickness of layer 1 ### Theta2: thickness of layer 2 ### Xoffset: distance along the x-axis between the center of the bounding box ### and the first interface l1-l2 if specified, in fraction of Theta1 ### i.e. 0 -> interface l2-l1 at center ### 1 -> interface l1-l2 at center ### otherwise, the center of BB corresponds to the center of a Layer1 ### i.e. Xoffset = .5 ### YL = np.sqrt((BB[1] - BB[0])**2 + (BB[3] - BB[2])**2) XC = (BB[0] + BB[1]) / 2. YC = (BB[2] + BB[3]) / 2. ZC = (BB[4] + BB[5]) / 2. Theta = Theta1 + Theta2 if Alpha > 0: l1 = (BB[0] - XC) * np.cos(np.radians(Alpha)) + (BB[2] - YC) * np.sin( np.radians(Alpha)) l2 = (BB[1] - XC) * np.cos(np.radians(Alpha)) + (BB[3] - YC) * np.sin( np.radians(Alpha)) else: l1 = (BB[0] - XC) * np.cos(np.radians(Alpha)) + (BB[3] - YC) * np.sin( np.radians(Alpha)) l2 = (BB[1] - XC) * np.cos(np.radians(Alpha)) + (BB[2] - YC) * np.sin( np.radians(Alpha)) n1 = int(np.ceil(l1 / Theta)) - 1 n2 = int(np.ceil(l2 / Theta)) + 1 LAYER1_IDs = Body_IDs[:] LAYER2_IDs = [] ### ### offset layers ### for i in range(n1, n2): X = XC + i * np.cos(np.radians(Alpha)) * Theta Y = YC + i * np.sin(np.radians(Alpha)) * Theta cubit.cmd('create brick X %f Y %f Z %f' % (Theta1, YL, BB[5] - BB[4])) tmp_ID = cubit.get_last_id("volume") cubit.cmd('move volume %i X %f Y %f Z %f' % (tmp_ID, X + Theta1 * (.5 - Xoffset), Y, ZC)) if not Alpha == 0.: ### cubit doesn't like rotations will 0 angle... cubit.cmd('create vertex X %f Y %f Z %f' % (X, Y, BB[4])) v1_ID = cubit.get_last_id("vertex") cubit.cmd('create vertex X %f Y %f Z %f' % (X, Y, BB[5])) v2_ID = cubit.get_last_id("vertex") cubit.cmd('rotate volume %i about vertex %i vertex %i angle %f' % (tmp_ID, v1_ID, v2_ID, Alpha)) cubit.cmd('delete vertex %i' % v1_ID) cubit.cmd('delete vertex %i' % v2_ID) (LAYER1_IDs, tmp_layer) = WebcutTool2(LAYER1_IDs, tmp_ID, delete=True) for l in tmp_layer: LAYER2_IDs.append(l) return (LAYER1_IDs, LAYER2_IDs)
def create_line(position): if position: last_curve_store=cubit.get_last_id("curve") command='create curve spline '+position cubit.silent_cmd(command) last_curve=cubit.get_last_id("curve") if last_curve != last_curve_store: return last_curve else: return False else: return False
def PacmanCoinCrystalCreate(R, r, lz, thetac, xc, ngrains, debug=False): import cubit ### ### create initial pacman ### (OUTSIDE_3D, CYL_3D) = PacmanCoinCreate(R, r, r, lz, thetac, xc) ### ### Create grains geometry ### circle = [0., 0., r] BB = [-R, R, -R, R] sites = SitesGenCircle2D(ngrains, circle, BB) (vertices, cells) = VoronoiGen(sites) realcells = VoronoiRemoveInfiniteCells(cells) newsites = SitesSmootherSphere(sites, vertices, cells, circle) (newvertices, newcells) = VoronoiGen(newsites) newrealcells = VoronoiRemoveInfiniteCells(newcells) ### if debug: print('\nregularized sites:') for site in newsites: print(site) print('\ncells:') for cell in newrealcells: print(cell) print('\nvertices:') for vertex in newvertices: print(vertex) ### ### chop grains ### GRAINS_3D = [] numgrains = 0 for i in range(len(newrealcells)): tmpgrain = GrainCreate(newvertices[newrealcells[i], :], lz) cubit.cmd("volume %i copy" % CYL_3D[0]) tmpBOX = cubit.get_last_id("volume") cubit.cmd("intersect volume %i %i keep" % (tmpBOX, tmpgrain)) offset = cubit.get_last_id("volume") if offset > tmpBOX: GRAINS_3D.append([]) for j in range(tmpBOX, offset): GRAINS_3D[numgrains].append(j + 1) cubit.cmd("delete volume %i %i" % (tmpgrain, tmpBOX)) GroupAddVolList("Grain%i" % (numgrains + 1), GRAINS_3D[numgrains]) numgrains += 1 cubit.cmd("delete volume %i" % CYL_3D[0]) cubit.cmd("delete CYL_3D") return OUTSIDE_3D, GRAINS_3D
def create_volume(surf1,surf2,method='loft'): if method == 'loft': cmd='create volume loft surface '+str(surf1)+' '+str(surf2) cubit.cmd(cmd) else: lcurve1=cubit.get_relatives("surface",surf1,"curve") lcurve2=cubit.get_relatives("surface",surf2,"curve") couples=coupling_curve(lcurve1,lcurve2) is_start=cubit.get_last_id('surface')+1 for cs in couples: cmd='create surface skin curve '+str(cs[1])+' '+str(cs[0]) cubit.cmd(cmd) is_stop=cubit.get_last_id('surface') cmd="create volume surface "+str(surf1)+' '+str(surf2)+' '+str(is_start)+' to '+str(is_stop)+" heal keep" cubit.cmd(cmd)
def create_volume(surf1,surf2,method='loft'): if method == 'loft': cmd='create volume loft surface '+str(surf1)+' '+str(surf2) cubit.cmd(cmd) else: lcurve1=cubit.get_relatives("surface",surf1,"curve") lcurve2=cubit.get_relatives("surface",surf2,"curve") couples=coupling_curve(lcurve1,lcurve2) is_start=cubit.get_last_id('surface')+1 for cs in couples: cmd='create surface skin curve '+str(cs[1])+' '+str(cs[0]) cubit.cmd(cmd) is_stop=cubit.get_last_id('surface') cmd="create volume surface "+str(surf1)+' '+str(surf2)+' '+str(is_start)+' to '+str(is_stop)+" heal" cubit.cmd(cmd)
def split(Ca, Cb, Ca1name='_1', Ca2name='_2'): # Ca : crossing curve (the cutted one) # Cb : crossed curve (the unchanged one) # Ca & Cb are objects # If Ca[1/2]name starts with a underscore, we keep the original name as a prefix #SPLIT Caname = Ca.entity_name() command = 'split curve ' + str(Ca.id()) + ' crossing curve ' + str(Cb.id()) print command cubit.cmd(command) # GET IDs lastID2 = cubit.get_last_id('curve') lastID1 = lastID2 - 1 Ca1 = cubit.curve(lastID1) # RENAMING if Ca1name[0] == '_': # Ca1.entity_name(Caname + Ca1name) command = 'curve ' + str( lastID1) + ' rename "' + Caname + Ca1name + '"' else: # Ca1.entity_name(Ca1name) command = 'curve ' + str(lastID1) + ' rename "' + Ca1name + '"' cubit.cmd(command) Ca2 = cubit.curve(lastID2) if Ca2name[0] == '_': # Ca2.entity_name(Caname + Ca2name) command = 'curve ' + str( lastID2) + ' rename "' + Caname + Ca2name + '"' else: # Ca2.entity_name(Ca2name) command = 'curve ' + str(lastID2) + ' rename "' + Ca2name + '"' cubit.cmd(command) return Ca1, Ca2
def createSpline2(pts): points = "" for p in pts: points += str(p) + " " cubit.cmd("create curve spline vertex %s" % (points)) splineID = cubit.get_last_id("curve") return splineID
def createSkinCurve2(curves): circles = "" for c in curves: circles += str(c) + " " cubit.cmd("create surface skin curve %s" % (circles)) surfID = cubit.get_last_id("surface") return surfID
def create_single_pml(n,coord,operator,limit,normal,distance,layers): idv1=cubit.get_last_id('volume')+1 if normal=='0 0 -1': txt="create element extrude face in surface with %s %s %s direction %s distance %s layers %s" cmd=txt % (coord,operator,limit,normal,distance,layers) else: txt="create element extrude face in (surf in vol %s) with %s %s %s direction %s distance %s layers %s" cmd=txt % (n,coord,operator,limit,normal,distance,layers) cubit.cmd(cmd) cmd='create mesh geometry Hex all except hex in vol all feature_angle 135.0' cubit.cmd(cmd) cmd='del hex all except hex in vol all' cubit.cmd(cmd) idv2=cubit.get_last_id('volume') idv=' '.join(str(x) for x in range(idv1,idv2+1)) return idv
def create_single_pml(n, coord, operator, limit, normal, distance, layers): idv1 = cubit.get_last_id('volume') + 1 if normal == '0 0 -1': txt = "create element extrude face in surface with %s %s %s direction %s distance %s layers %s" cmd = txt % (coord, operator, limit, normal, distance, layers) else: txt = "create element extrude face in (surf in vol %s) with %s %s %s direction %s distance %s layers %s" cmd = txt % (n, coord, operator, limit, normal, distance, layers) cubit.cmd(cmd) cmd = 'create mesh geometry Hex all except hex in vol all feature_angle 135.0' cubit.cmd(cmd) cmd = 'del hex all except hex in vol all' cubit.cmd(cmd) idv2 = cubit.get_last_id('volume') idv = ' '.join(str(x) for x in range(idv1, idv2 + 1)) return idv
def createCombineCurve(curves): cs = "" for c in curves: cs += str(c) + " " cubit.cmd("create curve combine curve %s" % (cs)) curveID = cubit.get_last_id("curve") return curveID
def add_beam(xr, hr, lr): cmd = 'create vertex ' + str(xr - lr / 2) + ' 0 0' cubit.cmd(cmd) id_v1 = cubit.get_last_id("vertex") cmd = 'create vertex ' + str(xr + lr / 2) + ' 0 0' cubit.cmd(cmd) id_v2 = cubit.get_last_id("vertex") cmd = 'create curve vertex ' + str(id_v1) + ' ' + str(id_v2) cubit.cmd(cmd) id_curv = cubit.get_last_id("curve") cmd = 'sweep curve ' + str(id_curv) + ' vector 0 0 -1 distance ' + str(hr) cubit.cmd(cmd) #cmd='delete curve '+str(id_curv); cubit.cmd(cmd) id_torre = cubit.get_last_id("volume") id_torre_surf_orig = cubit.get_last_id("surface") return id_torre, id_torre_surf_orig, id_curv
def create_line_v(ind,n,n2,step,data,unit): last_curve_store=cubit.get_last_id("curve") command='create curve spline ' for i in range(0,n): if i%step == 0: lon,lat,z=data[n2*i+ind][0],data[n2*i+ind][1],data[n2*i+ind][2] x,y=geo2utm(lon,lat,unit) txt=' Position ' + str(x) +' '+ str(y) +' '+ str(z) command=command+txt #print command cubit.silent_cmd(command) last_curve=cubit.get_last_id("curve") if last_curve != last_curve_store: return last_curve else: return 0
def split(Ca,Cb,Ca1name='_1',Ca2name='_2'): # Ca : crossing curve (the cutted one) # Cb : crossed curve (the unchanged one) # Ca & Cb are objects # If Ca[1/2]name starts with a underscore, we keep the original name as a prefix #SPLIT Caname = Ca.entity_name() command = 'split curve ' + str(Ca.id()) + ' crossing curve ' + str(Cb.id()) print command cubit.cmd(command) # GET IDs lastID2 = cubit.get_last_id('curve') lastID1 = lastID2 - 1 Ca1 = cubit.curve(lastID1) # RENAMING if Ca1name[0] == '_': # Ca1.entity_name(Caname + Ca1name) command = 'curve ' + str(lastID1) + ' rename "' + Caname + Ca1name +'"' else: # Ca1.entity_name(Ca1name) command = 'curve ' + str(lastID1) + ' rename "' + Ca1name +'"' cubit.cmd(command) Ca2 = cubit.curve(lastID2) if Ca2name[0] == '_': # Ca2.entity_name(Caname + Ca2name) command = 'curve ' + str(lastID2) + ' rename "' + Caname + Ca2name +'"' else: # Ca2.entity_name(Ca2name) command = 'curve ' + str(lastID2) + ' rename "' + Ca2name +'"' cubit.cmd(command) return Ca1,Ca2
def createSurfaceCurve2(curves): cc = "" for c in curves: cc += str(c) + " " cubit.cmd("create surface curve %s" % (cc)) surfID = cubit.get_last_id("surface") return surfID
def ywebcut(x): command='create planar surface with plane yplane offset '+str(x) cubit.cmd(command) last_surface=cubit.get_last_id("surface") command="webcut volume all tool volume in surf "+str(last_surface) cubit.cmd(command) command="del surf "+str(last_surface) cubit.cmd(command)
def list_2_curve(X,Y,name='',unit='*km'): Vlist = list_2_listofvertices(X,Y,unit) finalcmd = "create curve spline from vertex " + str(Vlist[0].id()) + " to " + str(Vlist[-1].id()) cubit.silent_cmd(finalcmd) C = cubit.curve(cubit.get_last_id('curve')) if name != '': C.entity_name(name) return C
def list_2_listofvertices(X,Y,unit='*km'): Vlis_out = [] for x,y in zip(X,Y): komand = "create vertex x { "+str(x)+ unit + "} y { "+str(y) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) Vlis_out.append(v) return Vlis_out
def ywebcut(x): command = 'create planar surface with plane yplane offset ' + str(x) cubit.cmd(command) last_surface = cubit.get_last_id("surface") command = "webcut volume all tool volume in surf " + str(last_surface) cubit.cmd(command) command = "del surf " + str(last_surface) cubit.cmd(command)
def load_curves(acis_filename): """ load the curves from acis files """ import os # # print acis_filename if acis_filename and os.path.exists(acis_filename): tmp_curve=cubit.get_last_id("curve") command = "import acis '"+acis_filename+"'" cubit.cmd(command) tmp_curve_after=cubit.get_last_id("curve") curves=' '.join(str(x) for x in range(tmp_curve+1,tmp_curve_after+1)) elif not os.path.exists(acis_filename): print str(acis_filename)+' not found' curves=None return [curves]
def list_2_listofvertices(X, Y, unit='*km'): Vlis_out = [] for x, y in zip(X, Y): komand = "create vertex x { " + str(x) + unit + "} y { " + str( y) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) Vlis_out.append(v) return Vlis_out
def list_2_curve(X, Y, name='', unit='*km'): Vlist = list_2_listofvertices(X, Y, unit) finalcmd = "create curve spline from vertex " + str( Vlist[0].id()) + " to " + str(Vlist[-1].id()) cubit.silent_cmd(finalcmd) C = cubit.curve(cubit.get_last_id('curve')) if name != '': C.entity_name(name) return C
def dico_2_listofvertices(dico,unit='*km'): Vlis_out = [] for name , xy in dico.iteritems(): komand = "create vertex x { "+str(xy[0])+ unit + "} y { "+str(xy[1]) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) v.entity_name(name) Vlis_out.append(v) return Vlis_out
def read_file_2_curve(path,name=''): Vlist = read_file_2_listofvertices(path) finalcmd = "create curve spline from vertex " + str(Vlist[0].id()) + " to " + str(Vlist[-1].id()) cubit.silent_cmd(finalcmd) C = cubit.curve(cubit.get_last_id('curve')) if name == '': C.entity_name(os.path.basename(path)) else: C.entity_name(name) return C
def load_curves(acis_filename): """ load the curves from acis files """ import os # # print acis_filename if acis_filename and os.path.exists(acis_filename): tmp_curve = cubit.get_last_id("curve") command = "import acis '" + acis_filename + "'" cubit.cmd(command) tmp_curve_after = cubit.get_last_id("curve") curves = ' '.join( str(x) for x in range(tmp_curve + 1, tmp_curve_after + 1)) elif not os.path.exists(acis_filename): print str(acis_filename) + ' not found' curves = None return [curves]
def dico_2_listofvertices(dico, unit='*km'): Vlis_out = [] for name, xy in dico.iteritems(): komand = "create vertex x { " + str(xy[0]) + unit + "} y { " + str( xy[1]) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) v.entity_name(name) Vlis_out.append(v) return Vlis_out
def read_file_2_listofvertices(path,unit='*km'): filein = open(path) Vlis_out = [] for line in filein: fields = line.split() # v = cubit.create_vertex(float(fields[0]),float(fields[1]),0) komand = "create vertex x { "+str(float(fields[0]))+ unit + "} y { "+str(float(fields[1])) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) Vlis_out.append(v) return Vlis_out
def read_file_2_curve(path, name=''): Vlist = read_file_2_listofvertices(path) finalcmd = "create curve spline from vertex " + str( Vlist[0].id()) + " to " + str(Vlist[-1].id()) cubit.silent_cmd(finalcmd) C = cubit.curve(cubit.get_last_id('curve')) if name == '': C.entity_name(os.path.basename(path)) else: C.entity_name(name) return C
def DCBCreate(LX, LY1, LY, LZ, EPSCRACK, LCRACK): import cubit import numpy as np ### vertices = np.empty([7, 3]) vertices[0, :] = [LCRACK, 0, -LZ / 2.] vertices[1, :] = [0, EPSCRACK / 2., -LZ / 2.] vertices[2, :] = [0, LY1 / 2., -LZ / 2.] vertices[3, :] = [LX, LY / 2., -LZ / 2.] vertices[4, :] = [LX, -LY / 2., -LZ / 2.] vertices[5, :] = [0, -LY1 / 2., -LZ / 2.] vertices[6, :] = [0, -EPSCRACK / 2., -LZ / 2.] ### ### Create vertices ### v_ID = [] for v in vertices: cubit.cmd("create vertex X %f Y %f Z %f" % (v[0], v[1], v[2])) v_ID.append(cubit.get_last_id("vertex")) ### ### Create curves ### c_ID = [] for v in range(len(v_ID)): cubit.cmd("create curve vertex %i vertex %i" % (v_ID[v], v_ID[(v + 1) % len(v_ID)])) c_ID.append(cubit.get_last_id("curve")) ### ### create surface ### cmd = "create surface curve" for c in c_ID: cmd += " %i" % c cubit.cmd(cmd) s_ID = cubit.get_last_id("surface") ### ### sweep volume ### cubit.cmd("sweep surface %i direction Z distance %f" % (s_ID, LZ)) DCB_3D = [cubit.get_last_id("volume")] return DCB_3D
def read_file_2_listofvertices(path, unit='*km'): filein = open(path) Vlis_out = [] for line in filein: fields = line.split() # v = cubit.create_vertex(float(fields[0]),float(fields[1]),0) komand = "create vertex x { " + str(float( fields[0])) + unit + "} y { " + str(float(fields[1])) + unit + "}" cubit.silent_cmd(komand) v = cubit.vertex(cubit.get_last_id('vertex')) Vlis_out.append(v) return Vlis_out
def PacmanLayeredCreateLayered(lx, ly, lz, alpha, theta1, theta2, thetacrack, xc=0): import cubit import numpy as np ### ### Create Main body ### cubit.cmd("Create cylinder height %f major radius %f minor radius %f" % (lz, lx, ly)) CYL = cubit.get_last_id("volume") ### ### Create wedge ### w_ID = [] cubit.cmd("create vertex X %f Y 0 Z %f" % (xc, -lz)) # cubit.cmd("create vertex X 0 Y 0 Z %f" % ( -lz)) w_ID.append(cubit.get_last_id("vertex")) X = 1.1 * np.max(lx, ly) * np.cos(np.radians(thetacrack / 2.)) Y = 1.1 * np.max(lx, ly) * np.sin(np.radians(thetacrack / 2.)) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, -Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create surface vertex %i %i %i" % (w_ID[0], w_ID[1], w_ID[2])) cubit.cmd("sweep surface %i perpendicular distance %f" % (cubit.get_last_id("surface"), 2 * lz)) WEDGE = cubit.get_last_id("volume") ### ### remove crack ### cubit.cmd("subtract volume %i from volume %i" % (WEDGE, CYL)) CYL_ID = [] CYL_ID.append(CYL) ### ### create layers ### bb = [-lx, lx, -ly, ly, -2. * lz, 2. * lz] print('CYL_ID, bb, alpha, theta1, theta2', CYL_ID, bb, alpha, theta1, theta2) (LAYER1_3D, LAYER2_3D) = Layer(CYL_ID, bb, alpha, theta1, theta2, 0.) ### ### imprint and merge ### cubit.cmd("imprint all") cubit.cmd("merge all") ### ### groups ### GroupAddVolList("LAYER1_3D", LAYER1_3D) GroupAddVolList("LAYER2_3D", LAYER2_3D) ### ### return LAYER1_3D and LAYER2_3D ### return LAYER1_3D, LAYER2_3D
def PacmanCreate(lx, ly, lz, thetacrack): import cubit import numpy as np ### ### Create Main body ### cubit.cmd("Create cylinder height %f major radius %f minor radius %f" % (lz, lx, ly)) CYL = cubit.get_last_id("volume") ### ### Create wedge ### w_ID = [] cubit.cmd("create vertex X 0 Y 0 Z %f" % (-lz)) w_ID.append(cubit.get_last_id("vertex")) X = 1.1 * np.max(lx, ly) * np.cos(np.radians(thetacrack / 2.)) Y = 1.1 * np.max(lx, ly) * np.sin(np.radians(thetacrack / 2.)) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, -Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create surface vertex %i %i %i" % (w_ID[0], w_ID[1], w_ID[2])) cubit.cmd("sweep surface %i perpendicular distance %f" % (cubit.get_last_id("surface"), 2 * lz)) WEDGE = cubit.get_last_id("volume") ### ### remove crack ### cubit.cmd("subtract volume %i from volume %i" % (WEDGE, CYL)) ### ### Return the ID of the cylinder ### return CYL
def project_curves(curves,top_surface): """ project curves on surface """ if not isinstance(curves,list): curves=curves.split() tmpc=[] for curve in curves: command = "project curve "+str(curve)+" onto surface "+str(top_surface) cubit.cmd(command) tmp_curve_after=cubit.get_last_id("curve") tmpc.append(tmp_curve_after) command = "del curve "+str(curve) cubit.cmd(command) return tmpc
def project_curves(curves, top_surface): """ project curves on surface """ if not isinstance(curves, list): curves = curves.split() tmpc = [] for curve in curves: command = "project curve " + str(curve) + " onto surface " + str( top_surface) cubit.cmd(command) tmp_curve_after = cubit.get_last_id("curve") tmpc.append(tmp_curve_after) command = "del curve " + str(curve) cubit.cmd(command) return tmpc
def PacmanCoinCreate(R, lx, ly, lz, thetacrack, xc=0.): import cubit import numpy as np ### ### Create Main body ### OUTSIDE_3D = [] cubit.cmd("Create cylinder height %f radius %f" % (lz, R)) OUTSIDE_3D.append(cubit.get_last_id("volume")) ### ### Create wedge ### w_ID = [] cubit.cmd("create vertex X %f Y 0 Z %f" % (xc, -lz)) w_ID.append(cubit.get_last_id("vertex")) X = 1.1 * R * np.cos(np.radians(thetacrack / 2.)) Y = 1.1 * R * np.sin(np.radians(thetacrack / 2.)) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, -Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create surface vertex %i %i %i" % (w_ID[0], w_ID[1], w_ID[2])) cubit.cmd("sweep surface %i perpendicular distance %f" % (cubit.get_last_id("surface"), 2 * lz)) WEDGE = cubit.get_last_id("volume") ### ### remove crack ### cubit.cmd("subtract volume %i from volume %i" % (WEDGE, OUTSIDE_3D[0])) ### ### Create center coin ### cubit.cmd("Create cylinder height %f major radius %f minor radius %f" % (lz, lx, ly)) CYL = cubit.get_last_id("volume") (OUTSIDE_3D, CYL_3D) = WebcutTool(OUTSIDE_3D, CYL, delete=True) ### ### create layers ### cubit.cmd("imprint all") cubit.cmd("merge all") ### ### groups ### GroupAddVolList("CYL_3D", CYL_3D) GroupAddVolList("OUTSIDE_3D", OUTSIDE_3D) return OUTSIDE_3D[0], CYL_3D
def createVertex(x,y,z): cubit.cmd("create vertex %f %f %f" % (x,y,z)) vertexID = cubit.get_last_id("vertex") return vertexID
def splitCurve2(c,v1, v2): cubit.cmd("split curve %d at vertex %d %d" % (c,v1,v2)) splineID = cubit.get_last_id("curve") return splineID
def MilledLayer(Body_IDs, BB, Alpha, Theta1, Theta2, secmin, Xoffset=.5): import cubit import numpy as np ### ### Body_ID: a single volume ID ### BB: bounding box in the form [xmin, xmax, ymin, ymax, zmin, zmax] ### Alpha: lamination angle ### Theta1: thickness of layer 1 ### Theta2: thickness of layer 2 ### secmin: the cross section after machining ### Xoffset: distance along the x-axis between the center of the bounding box ### and the first interface l1-l2 if specified, in fraction of Theta1 ### i.e. 0 -> interface l2-l1 at center ### 1 -> interface l1-l2 at center ### otherwise, the center of BB corresponds to the center of a Layer1 ### i.e. Xoffset = .5 ### YL = np.sqrt((BB[1] - BB[0])**2 + (BB[3] - BB[2])**2) ZL = BB[5] - BB[4] XC = (BB[0] + BB[1]) / 2. YC = (BB[2] + BB[3]) / 2. ZC = (BB[4] + BB[5]) / 2. Theta = Theta1 + Theta2 if Alpha > 0: l1 = (BB[0] - XC) * np.cos(np.radians(Alpha)) + (BB[2] - YC) * np.sin( np.radians(Alpha)) l2 = (BB[1] - XC) * np.cos(np.radians(Alpha)) + (BB[3] - YC) * np.sin( np.radians(Alpha)) else: l1 = (BB[0] - XC) * np.cos(np.radians(Alpha)) + (BB[3] - YC) * np.sin( np.radians(Alpha)) l2 = (BB[1] - XC) * np.cos(np.radians(Alpha)) + (BB[2] - YC) * np.sin( np.radians(Alpha)) n1 = int(np.ceil(l1 / Theta)) n2 = int(np.ceil(l2 / Theta)) for i in range(n1, n2): X = XC + i * np.cos( np.radians(Alpha)) * Theta + Theta1 * (Xoffset - .5) Y = YC + i * np.sin(np.radians(Alpha)) * Theta cubit.cmd('create brick X %f Y %f Z %f' % (Theta1, YL, ZL)) tmp_ID = cubit.get_last_id("volume") cubit.cmd('move volume %i X %f Y %f Z %f' % (tmp_ID, X, Y, ZL / 2. + secmin[1])) if not Alpha == 0.: ### cubit doesn't like rotations will 0 angle... cubit.cmd('create vertex X %f Y %f Z %f' % (X, Y, BB[4])) v1_ID = cubit.get_last_id("vertex") cubit.cmd('create vertex X %f Y %f Z %f' % (X, Y, BB[5])) v2_ID = cubit.get_last_id("vertex") cubit.cmd('rotate volume %i about vertex %i vertex %i angle %f' % (tmp_ID, v1_ID, v2_ID, Alpha)) cubit.cmd('delete vertex %i' % v1_ID) cubit.cmd('delete vertex %i' % v2_ID) (Body_IDs, tmp_layer) = WebcutTool(Body_IDs, tmp_ID, delete=False) cmd = "delete volume " for v in tmp_layer: cmd += " %i" % v cubit.cmd(cmd) cubit.cmd("move volume %i Z %f" % (tmp_ID, -ZL - secmin[1] + secmin[0])) (Body_IDs, tmp_layer) = WebcutTool(Body_IDs, tmp_ID, delete=True) cmd = "delete volume " for v in tmp_layer: cmd += " %i" % v cubit.cmd(cmd) return (Body_IDs)
def layercake_volume_ascii_regulargrid_mpiregularmap(filename=None,verticalsandwich=False,onlysurface=False): import sys import start as start # mpiflag,iproc,numproc,mpi = start.start_mpi() # numpy = start.start_numpy() cfg = start.start_cfg(filename=filename) from utilities import geo2utm, savegeometry,savesurf,cubit_command_check from math import sqrt # try: mpi.barrier() except: pass # # command = "comment '"+"PROC: "+str(iproc)+"/"+str(numproc)+" '" cubit_command_check(iproc,command,stop=True) if verticalsandwich: cubit.cmd("comment 'Starting Vertical Sandwich'") # #get icpuy,icpux values if mpiflag: icpux = iproc % cfg.nproc_xi icpuy = int(iproc / cfg.nproc_xi) else: icpuy=int(cfg.id_proc/cfg.nproc_xi) icpux=cfg.id_proc%cfg.nproc_xi # if cfg.geometry_format == 'ascii': #for the original surfaces #number of points in the files that describe the topography import local_volume if cfg.localdir_is_globaldir: if iproc == 0 or not mpiflag: coordx_0,coordy_0,elev_0,nx_0,ny_0=local_volume.read_grid(filename) print 'end of reading grd files '+str(nx_0*ny_0)+ ' points' else: pass if iproc == 0 or not mpiflag: coordx=mpi.bcast(coordx_0) else: coordx=mpi.bcast() if iproc == 0 or not mpiflag: coordy=mpi.bcast(coordy_0) else: coordy=mpi.bcast() if iproc == 0 or not mpiflag: elev=mpi.bcast(elev_0) else: elev=mpi.bcast() if iproc == 0 or not mpiflag: nx=mpi.bcast(nx_0) else: nx=mpi.bcast() if iproc == 0 or not mpiflag: ny=mpi.bcast(ny_0) else: ny=mpi.bcast() else: coordx,coordy,elev,nx,ny=local_volume.read_grid(filename) print str(iproc)+ ' end of receving grd files ' nx_segment=int(nx/cfg.nproc_xi)+1 ny_segment=int(ny/cfg.nproc_eta)+1 elif cfg.geometry_format=='regmesh': # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if cfg.depth_bottom != cfg.zdepth[0]: if iproc == 0: print 'the bottom of the block is at different depth than depth[0] in the configuration file' nx= cfg.nproc_xi+1 ny= cfg.nproc_eta+1 nx_segment=2 ny_segment=2 #if iproc == 0: print nx,ny,cfg.cpux,cfg.cpuy xp=(cfg.xmax-cfg.xmin)/float((nx-1)) yp=(cfg.ymax-cfg.ymin)/float((ny-1)) # elev=numpy.zeros([nx,ny,cfg.nz],float) coordx=numpy.zeros([nx,ny],float) coordy=numpy.zeros([nx,ny],float) # # xlength=(cfg.xmax-cfg.xmin)/float(cfg.nproc_xi) #length of x slide for chunk ylength=(cfg.ymax-cfg.ymin)/float(cfg.nproc_eta) #length of y slide for chunk nelem_chunk_x=1 nelem_chunk_y=1 ivxtot=nelem_chunk_x+1 ivytot=nelem_chunk_y+1 xstep=xlength #distance between vertex on x ystep=ylength for i in range(0,cfg.nz): elev[:,:,i] = cfg.zdepth[i] icoord=0 for iy in range(0,ny): for ix in range(0,nx): icoord=icoord+1 coordx[ix,iy]=cfg.xmin+xlength*(ix) coordy[ix,iy]=cfg.ymin+ylength*(iy) #print coordx,coordy,nx,ny # print 'end of building grid '+str(iproc) print 'number of point: ', len(coordx)*len(coordy) # #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #for each processor # nxmin_cpu=(nx_segment-1)*(icpux) nymin_cpu=(ny_segment-1)*(icpuy) nxmax_cpu=min(nx-1,(nx_segment-1)*(icpux+1)) nymax_cpu=min(ny-1,(ny_segment-1)*(icpuy+1)) #if iproc == 0: # print nx_segment,ny_segment,nx,ny # print icpux,icpuy,nxmin_cpu,nxmax_cpu # print icpux,icpuy,nymin_cpu,nymax_cpu # print coordx[0,0],coordx[nx-1,ny-1] # print coordy[0,0],coordy[nx-1,ny-1] # # icurve=0 isurf=0 ivertex=0 # #create vertex for inz in range(0,cfg.nz): if cfg.sea and inz==cfg.nz-1: #sea layer sealevel=True bathymetry=False elif cfg.sea and inz==cfg.nz-2: #bathymetry layer sealevel=False bathymetry=True else: sealevel=False bathymetry=False print sealevel,bathymetry if cfg.bottomflat and inz == 0: #bottom layer # if cfg.geometry_format == 'ascii': lv=cubit.get_last_id("vertex") x_current,y_current=(coordx[nxmin_cpu,nymin_cpu],coordy[nxmin_cpu,nymin_cpu]) cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=(coordx[nxmin_cpu,nymax_cpu],coordy[nxmin_cpu,nymax_cpu]) cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=(coordx[nxmax_cpu,nymax_cpu],coordy[nxmax_cpu,nymax_cpu]) cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=(coordx[nxmax_cpu,nymin_cpu],coordy[nxmax_cpu,nymin_cpu]) cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # lv2=cubit.get_last_id("vertex") cubitcommand= 'create surface vertex '+str(lv+1)+' to '+str(lv2) cubit.cmd(cubitcommand) # isurf = isurf + 1 else: lv=cubit.get_last_id("vertex") x_current,y_current=geo2utm(coordx[nxmin_cpu,nymin_cpu],coordy[nxmin_cpu,nymin_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmin_cpu,nymax_cpu],coordy[nxmin_cpu,nymax_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmax_cpu,nymax_cpu],coordy[nxmax_cpu,nymax_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmax_cpu,nymin_cpu],coordy[nxmax_cpu,nymin_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( cfg.depth_bottom ) cubit.cmd(cubitcommand) # lv2=cubit.get_last_id("vertex") cubitcommand= 'create surface vertex '+str(lv+1)+' to '+str(lv2) cubit.cmd(cubitcommand) # isurf = isurf + 1 else: if cfg.geometry_format == 'regmesh': zvertex=cfg.zdepth[inz] lv=cubit.get_last_id("vertex") x_current,y_current=geo2utm(coordx[nxmin_cpu,nymin_cpu],coordy[nxmin_cpu,nymin_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( zvertex ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmin_cpu,nymax_cpu],coordy[nxmin_cpu,nymax_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( zvertex ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmax_cpu,nymax_cpu],coordy[nxmax_cpu,nymax_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( zvertex ) cubit.cmd(cubitcommand) # x_current,y_current=geo2utm(coordx[nxmax_cpu,nymin_cpu],coordy[nxmax_cpu,nymin_cpu],'utm') cubitcommand= 'create vertex '+ str( x_current )+ ' ' + str( y_current) +' '+ str( zvertex ) cubit.cmd(cubitcommand) # cubitcommand= 'create surface vertex '+str(lv+1)+' '+str(lv+2)+' '+str(lv+3)+' '+str(lv+4) cubit.cmd(cubitcommand) # isurf = isurf + 1 elif cfg.geometry_format == 'ascii': vertex=[] for iy in range(nymin_cpu,nymax_cpu+1): ivx=0 for ix in range(nxmin_cpu,nxmax_cpu+1): zvertex=elev[ix,iy,inz] #zvertex=adjust_sea_layers(zvertex,sealevel,bathymetry,cfg) x_current,y_current=(coordx[ix,iy],coordy[ix,iy]) # vertex.append(' Position '+ str( x_current ) +' '+ str( y_current )+' '+ str( zvertex ) ) # print 'proc',iproc, 'vertex list created....',len(vertex) n=max(nx,ny) uline=[] vline=[] iv=0 cubit.cmd("set info off") cubit.cmd("set echo off") cubit.cmd("set journal off") for iy in range(0,nymax_cpu-nymin_cpu+1): positionx='' for ix in range(0,nxmax_cpu-nxmin_cpu+1): positionx=positionx+vertex[iv] iv=iv+1 command='create curve spline '+positionx cubit.cmd(command) #print command uline.append( cubit.get_last_id("curve") ) for ix in range(0,nxmax_cpu-nxmin_cpu+1): positiony='' for iy in range(0,nymax_cpu-nymin_cpu+1): positiony=positiony+vertex[ix+iy*(nxmax_cpu-nxmin_cpu+1)] command='create curve spline '+positiony cubit.cmd(command) #print command vline.append( cubit.get_last_id("curve") ) # cubit.cmd("set info "+cfg.cubit_info) cubit.cmd("set echo "+cfg.echo_info) cubit.cmd("set journal "+cfg.jou_info) # # print 'proc',iproc, 'lines created....',len(uline),'*',len(vline) umax=max(uline) umin=min(uline) vmax=max(vline) vmin=min(vline) ner=cubit.get_error_count() cubitcommand= 'create surface net u curve '+ str( umin )+' to '+str( umax )+ ' v curve '+ str( vmin )+ ' to '+str( vmax )+' heal' cubit.cmd(cubitcommand) ner2=cubit.get_error_count() if ner == ner2: command = "del curve all" cubit.cmd(command) isurf=isurf+1 # else: raise NameError, 'error, check geometry_format, it should be ascii or regmesh' # # cubitcommand= 'del vertex all' cubit.cmd(cubitcommand) if cfg.save_surface_cubit: savegeometry(iproc=iproc,surf=True,filename=filename) # # #!create volume if not onlysurface: if cfg.nz == 1: nsurface=2 else: nsurface=cfg.nz for inz in range(1,nsurface): ner=cubit.get_error_count() create_volume(inz,inz+1,method=cfg.volumecreation_method) ner2=cubit.get_error_count() if ner == ner2 and not cfg.debug_geometry: #cubitcommand= 'del surface 1 to '+ str( cfg.nz ) cubitcommand= 'del surface all' cubit.cmd(cubitcommand) list_vol=cubit.parse_cubit_list("volume","all") if len(list_vol) > 1: cubitcommand= 'imprint volume all' cubit.cmd(cubitcommand) cubitcommand= 'merge all' cubit.cmd(cubitcommand) #ner=cubit.get_error_count() #cubitcommand= 'composite create curve in vol all' #cubit.cmd(cubitcommand) savegeometry(iproc,filename=filename) #if cfg.geological_imprint: # curvesname=[cfg.outlinebasin_curve,cfg.transition_curve,cfg.faulttrace_curve] # outdir=cfg.working_dir # imprint_topography_with_geological_outline(curvesname,outdir) # # cubit.cmd("set info "+cfg.cubit_info) cubit.cmd("set echo "+cfg.echo_info) cubit.cmd("set journal "+cfg.jou_info)
def createArcNormal(r,c,n,sa,ea): cubit.cmd("create curve arc radius %f center location at vertex %d normal %f %f %f start angle %f stop angle %f" % (r,c,n[0],n[1],n[2],sa,ea)) arcID = cubit.get_last_id("curve") return arcID
def SPacmanCoinLayeredCreate(LX, LY, lx, ly, lz, alpha, theta1, theta2, thetacrack, xc=0): import cubit import numpy as np ### ### Create Main body ### OUTSIDE_3D = [] cubit.cmd("Create brick X %f Y %f Z %f" % (LX, LY, lz)) OUTSIDE_3D.append(cubit.get_last_id("volume")) ### ### Create wedge ### w_ID = [] cubit.cmd("create vertex X %f Y 0 Z %f" % (xc, -lz)) w_ID.append(cubit.get_last_id("vertex")) X = 1.1 * LX / 2. * np.cos(np.radians(thetacrack / 2.)) Y = 1.1 * LX / 2. * np.sin(np.radians(thetacrack / 2.)) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create vertex X %f Y %f Z %f" % (-X, -Y, -lz)) w_ID.append(cubit.get_last_id("vertex")) cubit.cmd("create surface vertex %i %i %i" % (w_ID[0], w_ID[1], w_ID[2])) cubit.cmd("sweep surface %i perpendicular distance %f" % (cubit.get_last_id("surface"), 2 * lz)) WEDGE = cubit.get_last_id("volume") ### ### remove crack ### cubit.cmd("subtract volume %i from volume %i" % (WEDGE, OUTSIDE_3D[0])) ### ### Create center coin ### cubit.cmd("Create brick X %f Y %f Z %f" % (lx, ly, lz)) PM = cubit.get_last_id("volume") (OUTSIDE_3D, PM_ID) = WebcutTool(OUTSIDE_3D, PM, delete=True) ### ### create layers ### bb = [ -1.1 * lx / 2., 1.1 * lx / 2., -1.1 * ly / 2., 1.1 * ly / 2., -2. * lz, 2. * lz ] print('PM_ID, bb, alpha, theta1, theta2', PM_ID, bb, alpha, theta1, theta2) (LAYER1_3D, LAYER2_3D) = Layer(PM_ID, bb, alpha, theta1, theta2, 0.) ### ### imprint and merge ### cubit.cmd("imprint all") cubit.cmd("merge all") ### ### groups ### GroupAddVolList("LAYER1_3D", LAYER1_3D) GroupAddVolList("LAYER2_3D", LAYER2_3D) GroupAddVolList("OUTSIDE_3D", OUTSIDE_3D) ### ### return LAYER1_3D and LAYER2_3D ### return OUTSIDE_3D, LAYER1_3D, LAYER2_3D
def surface_skin(isurface=0,cfgname=None): """ create an acis surface interpolating no-intersecting lines """ import sys,os from math import sqrt from utilities import geo2utm import start as start # # cubit = start.start_cubit() cfg = start.start_cfg(cfgname) # def define_next_line(directionx,directiony,n,data): ndata=len(data) command='' ind=n try: record=data[ind] except: return False,False try: x,y,z=map(float,record.split()) except: return False,False txt=' Position ' + record command=command+txt x_store,y_store,z_store = x,y,z icount=1 while True: ind+=1 if ind >= ndata: return ind,command record=data[ind] try: x,y,z=map(float,record.split()) except: return ind,command dx,dy = x-x_store,y-y_store if directionx == 0 and dy/abs(dy) * directiony >= 0: txt=' Position ' + record command=command+txt icount+=1 x_store,y_store,z_store = x,y,z elif directiony == 0 and dx/abs(dx) == directionx : txt=' Position ' + record command=command+txt icount+=1 x_store,y_store,z_store = x,y,z else: if icount==1: x,y,z=x_store+1e-4*directionx,y_store+1e-4*directiony,z_store txt=' Position ' +str(x)+ ' '+str(y)+ ' '+str(z) command=command+txt return ind,command def create_line(position): if position: last_curve_store=cubit.get_last_id("curve") command='create curve spline '+position cubit.silent_cmd(command) last_curve=cubit.get_last_id("curve") if last_curve != last_curve_store: return last_curve else: return False else: return False command = "reset" cubit.cmd(command) # position=True # try: grdfile = open(cfg.surface_name[isurface], 'r') except: raise NameError, 'No such file or directory: '+ str( cfg.surface_name[isurface] ) # directionx=cfg.directionx[isurface] directiony=cfg.directiony[isurface] step=cfg.step[isurface] position=True curveskin=[] count_line=0 data=grdfile.read().split('\n') ndata=len(data) n=0 # # command = "set echo off" cubit.cmd(command) command = "set journal off" cubit.cmd(command) command = "set info off" cubit.cmd(command) # while position: index,position=define_next_line(directionx,directiony,n,data) if n%step == 0: curve=create_line(position) if curve: curveskin.append(curve) elif n%step != 0 and not position: curve=create_line(position) if curve: curveskin.append(curve) n=index umax=max(curveskin) umin=min(curveskin) print 'create surface skin curve '+ str( umin )+' to '+str( umax ) cubitcommand= 'create surface skin curve '+ str( umin )+' to '+str( umax ) cubit.cmd(cubitcommand) command = "del curve all" cubit.cmd(command) last_surface=cubit.get_last_id("surface") command = "regularize surf "+str(last_surface) cubit.cmd(command) # suff=cfg.surface_name[isurface].split('/') command = "save as '"+cfg.working_dir+"/surf_"+suff[-1]+".cub' overwrite" cubit.cmd(command) # # # cubit.cmd("set info "+cfg.cubit_info) cubit.cmd("set echo "+cfg.echo_info) cubit.cmd("set journal "+cfg.jou_info)
fid1.write("%04.1f\n" % (thick_l3)) fid1.write("%04.1f\n" % (thick_l4)) fid3.write("%04.1f\n" % (xr)) fid1.close() fid3.close() #creating first layer of soil cmd = 'create vertex ' + str(x1) + ' ' + str(y1) + ' 0' cubit.cmd(cmd) cmd = 'create vertex ' + str(x2) + ' ' + str(y2) + ' 0' cubit.cmd(cmd) cmd = 'create curve vertex 1 2' cubit.cmd(cmd) cmd = 'sweep curve 1 vector 0 0 -1 distance ' + str(thick_l1) cubit.cmd(cmd) id_base0 = cubit.get_last_id("volume") #cmd='delete curve 1'; cubit.cmd(cmd) cmd = 'rotate 90 about world X' cubit.cmd(cmd) #creating second layer of soil cubit.cmd('create vertex x ' + str(x1) + ' ' + str(y1) + ' ' + str(-thick_l1)) id_v1 = cubit.get_last_id("vertex") print 'v1', id_v1 cubit.cmd('create vertex x ' + str(x2) + ' ' + str(y2) + ' ' + str(-thick_l1)) id_v2 = cubit.get_last_id("vertex") print 'v2', id_v2 cubit.cmd('create vertex x ' + str(x2) + ' ' + str(y2) + ' ' + str(-(thick_l1 + thick_l2))) id_v3 = cubit.get_last_id("vertex") print 'v3', id_v3
def saveMesh3D(self): cubit.cmd("brick x 5000 y 5000 z 5000") cubit.cmd("create cylinder height 4000 radius 500") cubit.cmd("subtract body 2 from body 1") volID = cubit.get_last_id("volume") self.vol = volID self.mesh() nNodes = cubit.get_node_count() meshFile = open(folder+"mesh3D2.xml", 'w') meshFile.write('<mesh celltype="tetrahedron" dim="3">\n') meshFile.write(' <nodes size="%d">\n' % (nNodes)) for x in range(0, nNodes): coords = cubit.get_nodal_coordinates(x+1) meshFile.write(' <node id="%d" x="%f" y="%f" z="%f"/>\n' % (x,coords[0],coords[1],coords[2])) meshFile.write(' </nodes>\n') nTets = cubit.get_tet_count() meshFile.write(' <elements size="%d">\n' % (nTets)) for x in range(0, nTets): nodes = cubit.get_connectivity("tet", x+1) meshFile.write(' <element id="%d" v0="%d" v1="%d" v2="%d" v3="%d"/>\n' % (x,nodes[0]-1,nodes[1]-1,nodes[2]-1,nodes[3]-1)) meshFile.write(' </elements>\n') meshFile.write(' <element_data type="fiber_transversely_isotropic">\n') for x in range(0, nTets): meshFile.write(' <element id="%d">\n' %(x)) meshFile.write(' <fiber>1.000000,0.000000,0.000000</fiber>\n') meshFile.write(' </element>\n') meshFile.write(' </element_data>\n') meshFile.write(' <boundary celltype="triangle" dim="2">\n') bsurfs = [10, 11, 12] ec = 0 for x in range(0, len(bsurfs)): tris = cubit.get_surface_tris(bsurfs[x]) surf = cubit.surface(bsurfs[x]) for y in range(0, len(tris)): cp = cubit.get_center_point("tri", tris[y]) norm = surf.normal_at([cp[0],cp[1],cp[2]]) #cubit.cmd("create curve location %f %f %f direction %f %f %f length %f" % (cp[0],cp[1],cp[2],norm[0],norm[1],norm[2],200)) nodes = cubit.get_connectivity("tri", tris[y]) element = [nodes[0]-1, nodes[1]-1, nodes[2]-1] meshFile.write(' <element id="%d" marker="%d" v0="%d" v1="%d" v2="%d" nx="%f" ny="%f" nz="%f"/>\n' % (ec,1.0,element[0],element[1],element[2],norm[0],norm[1],norm[2])) ec = ec+1 meshFile.write(' </boundary>\n') meshFile.write('</mesh>\n') meshFile.write('<poisson>\n') meshFile.write(' <neumann>\n') meshFile.write(' <node id="1" marker="1" value="0.5" />\n') meshFile.write(' </neumann>\n') meshFile.write('</poisson>\n') #meshFile.write('<electrophysiology>\n') #meshFile.write(' <stimuli number="1">\n') #bb = cubit.get_bounding_box("volume", self.vol) #x0 = bb[0] #x1 = 0.8*x0 + 0.2*bb[1] #y0 = bb[3] #y1 = 0.8*y0 + 0.2*bb[4] #z0 = bb[6] #z1 = 0.8*z0 + 0.2*bb[7] #meshFile.write(' <stim start="0.00" duration="4.00" value="-35.7140" x0="%f" x1="%f" y0="%f" y1="%f" z0="%f" z1="%f" />\n' % (x0,x1,y0,y1,z0,z1)) #meshFile.write(' </stimuli>\n') #meshFile.write('</electrophysiology>\n') meshFile.close()
def saveMesh2D2(self): cubit.cmd("create surface rectangle width 5000 height 5000 zplane") cubit.cmd("create surface rectangle width 1000 height 1000 zplane") cubit.cmd("subtract body 2 from body 1") surfID = cubit.get_last_id("surface") cubit.cmd("surface all size auto factor 4") cubit.cmd("surface all scheme TriMesh") cubit.cmd("mesh surface all") nNodes = cubit.get_node_count() meshFile = open(folder+"mesh2D2.xml", 'w') meshFile.write('<mesh celltype="triangle" dim="2">\n') meshFile.write(' <nodes size="%d">\n' % (nNodes)) for x in range(0, nNodes): coords = cubit.get_nodal_coordinates(x+1) meshFile.write(' <node id="%d" x="%f" y="%f" z="%f"/>\n' % (x,coords[0],coords[1],coords[2])) meshFile.write(' </nodes>\n') tris = cubit.get_surface_tris(surfID) meshFile.write(' <elements size="%d">\n' % (len(tris))) for x in range(0, len(tris)): nd = cubit.get_connectivity("tri", tris[x]) meshFile.write(' <element id="%d" v0="%d" v1="%d" v2="%d"/>\n' % (x,nd[0]-1,nd[1]-1,nd[2]-1)) meshFile.write(' </elements>\n') meshFile.write(' <element_data type="fiber_transversely_isotropic">\n') for x in range(0, len(tris)): meshFile.write(' <element id="%d">\n' %(x)) meshFile.write(' <fiber>1.000000,0.000000,0.000000</fiber>\n') meshFile.write(' </element>\n') meshFile.write(' </element_data>\n') meshFile.write(' <boundary celltype="line" dim="1">\n') eds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] ec = 1 surf = cubit.surface(surfID) for y in range(0, len(eds)): nodes = cubit.get_connectivity("edge", eds[y]) element = [nodes[0]-1, nodes[1]-1] #cp = cubit.get_center_point("edge", eds[y]) #norm = surf.normal_at([cp[0],cp[1],cp[2]]) #cubit.cmd("create curve location %f %f %f direction %f %f %f length %f" % (cp[0],cp[1],cp[2], norm[0], norm[1], norm[2], 200)) #ec = ec+1 #meshFile.write(' <element id="%d" marker="%d" v0="%d" v1="%d" nx="%f" ny="%f" nz="%f"/>\n' % (ec,1,element[0],element[1], norm[0], norm[1], norm[2])) #meshFile.write(' <element id="%d" marker="%d" v0="%d" v1="%d" v2="%d"/>\n' % (ec+1,2,element[0],element[1],element[2])) meshFile.write(' </boundary>\n') meshFile.write('</mesh>\n') meshFile.write('<poisson>\n') meshFile.write(' <neumann>\n') meshFile.write(' <node id="1" marker="1" value="1.0" />\n') meshFile.write(' </neumann>\n') #meshFile.write(' <dirichlet>\n') #meshFile.write(' <node id="2" marker="2" value="0.0" />\n') #meshFile.write(' </dirichlet>\n') meshFile.write('</poisson>\n') meshFile.write('<electrophysiology>\n') meshFile.write(' <stimuli number="1">\n') bb = cubit.get_bounding_box("surface", surfID) x0 = bb[0] x1 = 0.8*x0 + 0.2*bb[1] y0 = bb[3] y1 = 0.8*y0 + 0.2*bb[4] #z0 = bb[6] #z1 = 0.8*z0 + 0.2*bb[7] meshFile.write(' <stim start="0.00" duration="4.00" value="-35.7140" x0="%f" x1="%f" y0="%f" y1="%f" />\n' % (x0,x1,y0,y1)) meshFile.write(' </stimuli>\n') meshFile.write('</electrophysiology>\n') meshFile.close()
def createVertexOnCurveFraction(c,f): cubit.cmd("create vertex on curve %d fraction %f from start" % (c,f)) vertexID = cubit.get_last_id("vertex") return vertexID
def createSweep(s,c): cubit.cmd("sweep surface %d along curve %d" % (s,c)) volID = cubit.get_last_id("volume") return volID
def createVertexOnCurveDistance(c,d): cubit.cmd("create vertex on curve %d distance %f from start" % (c,d)) vertexID = cubit.get_last_id("vertex") return vertexID
def layercake_volume_ascii_regulargrid_mpiregularmap(filename=None, verticalsandwich=False, onlysurface=False): import sys import start as start # mpiflag, iproc, numproc, mpi = start.start_mpi() # numpy = start.start_numpy() cfg = start.start_cfg(filename=filename) from utilities import geo2utm, savegeometry, savesurf, cubit_command_check from math import sqrt # try: mpi.barrier() except: pass # # command = "comment '" + "PROC: " + str(iproc) + "/" + str(numproc) + " '" cubit_command_check(iproc, command, stop=True) if verticalsandwich: cubit.cmd("comment 'Starting Vertical Sandwich'") # #get icpuy,icpux values if mpiflag: icpux = iproc % cfg.nproc_xi icpuy = int(iproc / cfg.nproc_xi) else: icpuy = int(cfg.id_proc / cfg.nproc_xi) icpux = cfg.id_proc % cfg.nproc_xi # if cfg.geometry_format == 'ascii': #for the original surfaces #number of points in the files that describe the topography import local_volume if cfg.localdir_is_globaldir: if iproc == 0 or not mpiflag: coordx_0, coordy_0, elev_0, nx_0, ny_0 = local_volume.read_grid( filename) print 'end of reading grd files ' + str( nx_0 * ny_0) + ' points' else: pass if iproc == 0 or not mpiflag: coordx = mpi.bcast(coordx_0) else: coordx = mpi.bcast() if iproc == 0 or not mpiflag: coordy = mpi.bcast(coordy_0) else: coordy = mpi.bcast() if iproc == 0 or not mpiflag: elev = mpi.bcast(elev_0) else: elev = mpi.bcast() if iproc == 0 or not mpiflag: nx = mpi.bcast(nx_0) else: nx = mpi.bcast() if iproc == 0 or not mpiflag: ny = mpi.bcast(ny_0) else: ny = mpi.bcast() else: coordx, coordy, elev, nx, ny = local_volume.read_grid(filename) print str(iproc) + ' end of receving grd files ' nx_segment = int(nx / cfg.nproc_xi) + 1 ny_segment = int(ny / cfg.nproc_eta) + 1 elif cfg.geometry_format == 'regmesh': # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if cfg.depth_bottom != cfg.zdepth[0]: if iproc == 0: print 'the bottom of the block is at different depth than depth[0] in the configuration file' nx = cfg.nproc_xi + 1 ny = cfg.nproc_eta + 1 nx_segment = 2 ny_segment = 2 #if iproc == 0: print nx,ny,cfg.cpux,cfg.cpuy xp = (cfg.xmax - cfg.xmin) / float((nx - 1)) yp = (cfg.ymax - cfg.ymin) / float((ny - 1)) # elev = numpy.zeros([nx, ny, cfg.nz], float) coordx = numpy.zeros([nx, ny], float) coordy = numpy.zeros([nx, ny], float) # # xlength = (cfg.xmax - cfg.xmin) / float( cfg.nproc_xi) #length of x slide for chunk ylength = (cfg.ymax - cfg.ymin) / float( cfg.nproc_eta) #length of y slide for chunk nelem_chunk_x = 1 nelem_chunk_y = 1 ivxtot = nelem_chunk_x + 1 ivytot = nelem_chunk_y + 1 xstep = xlength #distance between vertex on x ystep = ylength for i in range(0, cfg.nz): elev[:, :, i] = cfg.zdepth[i] icoord = 0 for iy in range(0, ny): for ix in range(0, nx): icoord = icoord + 1 coordx[ix, iy] = cfg.xmin + xlength * (ix) coordy[ix, iy] = cfg.ymin + ylength * (iy) #print coordx,coordy,nx,ny # print 'end of building grid ' + str(iproc) print 'number of point: ', len(coordx) * len(coordy) # #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #for each processor # nxmin_cpu = (nx_segment - 1) * (icpux) nymin_cpu = (ny_segment - 1) * (icpuy) nxmax_cpu = min(nx - 1, (nx_segment - 1) * (icpux + 1)) nymax_cpu = min(ny - 1, (ny_segment - 1) * (icpuy + 1)) #if iproc == 0: # print nx_segment,ny_segment,nx,ny # print icpux,icpuy,nxmin_cpu,nxmax_cpu # print icpux,icpuy,nymin_cpu,nymax_cpu # print coordx[0,0],coordx[nx-1,ny-1] # print coordy[0,0],coordy[nx-1,ny-1] # # icurve = 0 isurf = 0 ivertex = 0 # #create vertex for inz in range(0, cfg.nz): if cfg.sea and inz == cfg.nz - 1: #sea layer sealevel = True bathymetry = False elif cfg.sea and inz == cfg.nz - 2: #bathymetry layer sealevel = False bathymetry = True else: sealevel = False bathymetry = False print sealevel, bathymetry if cfg.bottomflat and inz == 0: #bottom layer # if cfg.geometry_format == 'ascii': lv = cubit.get_last_id("vertex") x_current, y_current = (coordx[nxmin_cpu, nymin_cpu], coordy[nxmin_cpu, nymin_cpu]) cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = (coordx[nxmin_cpu, nymax_cpu], coordy[nxmin_cpu, nymax_cpu]) cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = (coordx[nxmax_cpu, nymax_cpu], coordy[nxmax_cpu, nymax_cpu]) cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = (coordx[nxmax_cpu, nymin_cpu], coordy[nxmax_cpu, nymin_cpu]) cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # lv2 = cubit.get_last_id("vertex") cubitcommand = 'create surface vertex ' + str( lv + 1) + ' to ' + str(lv2) cubit.cmd(cubitcommand) # isurf = isurf + 1 else: lv = cubit.get_last_id("vertex") x_current, y_current = geo2utm(coordx[nxmin_cpu, nymin_cpu], coordy[nxmin_cpu, nymin_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmin_cpu, nymax_cpu], coordy[nxmin_cpu, nymax_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmax_cpu, nymax_cpu], coordy[nxmax_cpu, nymax_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmax_cpu, nymin_cpu], coordy[nxmax_cpu, nymin_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(cfg.depth_bottom) cubit.cmd(cubitcommand) # lv2 = cubit.get_last_id("vertex") cubitcommand = 'create surface vertex ' + str( lv + 1) + ' to ' + str(lv2) cubit.cmd(cubitcommand) # isurf = isurf + 1 else: if cfg.geometry_format == 'regmesh': zvertex = cfg.zdepth[inz] lv = cubit.get_last_id("vertex") x_current, y_current = geo2utm(coordx[nxmin_cpu, nymin_cpu], coordy[nxmin_cpu, nymin_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(zvertex) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmin_cpu, nymax_cpu], coordy[nxmin_cpu, nymax_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(zvertex) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmax_cpu, nymax_cpu], coordy[nxmax_cpu, nymax_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(zvertex) cubit.cmd(cubitcommand) # x_current, y_current = geo2utm(coordx[nxmax_cpu, nymin_cpu], coordy[nxmax_cpu, nymin_cpu], 'utm') cubitcommand = 'create vertex ' + str(x_current) + ' ' + str( y_current) + ' ' + str(zvertex) cubit.cmd(cubitcommand) # cubitcommand = 'create surface vertex ' + str( lv + 1) + ' ' + str(lv + 2) + ' ' + str(lv + 3) + ' ' + str(lv + 4) cubit.cmd(cubitcommand) # isurf = isurf + 1 elif cfg.geometry_format == 'ascii': vertex = [] for iy in range(nymin_cpu, nymax_cpu + 1): ivx = 0 for ix in range(nxmin_cpu, nxmax_cpu + 1): zvertex = elev[ix, iy, inz] #zvertex=adjust_sea_layers(zvertex,sealevel,bathymetry,cfg) x_current, y_current = (coordx[ix, iy], coordy[ix, iy]) # vertex.append(' Position ' + str(x_current) + ' ' + str(y_current) + ' ' + str(zvertex)) # print 'proc', iproc, 'vertex list created....', len(vertex) n = max(nx, ny) uline = [] vline = [] iv = 0 cubit.cmd("set info off") cubit.cmd("set echo off") cubit.cmd("set journal off") for iy in range(0, nymax_cpu - nymin_cpu + 1): positionx = '' for ix in range(0, nxmax_cpu - nxmin_cpu + 1): positionx = positionx + vertex[iv] iv = iv + 1 command = 'create curve spline ' + positionx cubit.cmd(command) #print command uline.append(cubit.get_last_id("curve")) for ix in range(0, nxmax_cpu - nxmin_cpu + 1): positiony = '' for iy in range(0, nymax_cpu - nymin_cpu + 1): positiony = positiony + vertex[ ix + iy * (nxmax_cpu - nxmin_cpu + 1)] command = 'create curve spline ' + positiony cubit.cmd(command) #print command vline.append(cubit.get_last_id("curve")) # cubit.cmd("set info " + cfg.cubit_info) cubit.cmd("set echo " + cfg.echo_info) cubit.cmd("set journal " + cfg.jou_info) # # print 'proc', iproc, 'lines created....', len(uline), '*', len( vline) umax = max(uline) umin = min(uline) vmax = max(vline) vmin = min(vline) ner = cubit.get_error_count() cubitcommand = 'create surface net u curve ' + str( umin) + ' to ' + str(umax) + ' v curve ' + str( vmin) + ' to ' + str(vmax) + ' heal' cubit.cmd(cubitcommand) ner2 = cubit.get_error_count() if ner == ner2: command = "del curve all" cubit.cmd(command) isurf = isurf + 1 # else: raise NameError, 'error, check geometry_format, it should be ascii or regmesh' # # cubitcommand = 'del vertex all' cubit.cmd(cubitcommand) if cfg.save_surface_cubit: savegeometry(iproc=iproc, surf=True, filename=filename) # # #!create volume if not onlysurface: if cfg.nz == 1: nsurface = 2 else: nsurface = cfg.nz for inz in range(1, nsurface): ner = cubit.get_error_count() create_volume(inz, inz + 1, method=cfg.volumecreation_method) ner2 = cubit.get_error_count() if ner == ner2 and not cfg.debug_geometry: #cubitcommand= 'del surface 1 to '+ str( cfg.nz ) cubitcommand = 'del surface all' cubit.cmd(cubitcommand) list_vol = cubit.parse_cubit_list("volume", "all") if len(list_vol) > 1: cubitcommand = 'imprint volume all' cubit.cmd(cubitcommand) cubitcommand = 'merge all' cubit.cmd(cubitcommand) #ner=cubit.get_error_count() #cubitcommand= 'composite create curve in vol all' #cubit.cmd(cubitcommand) savegeometry(iproc, filename=filename) #if cfg.geological_imprint: # curvesname=[cfg.outlinebasin_curve,cfg.transition_curve,cfg.faulttrace_curve] # outdir=cfg.working_dir # imprint_topography_with_geological_outline(curvesname,outdir) # # cubit.cmd("set info " + cfg.cubit_info) cubit.cmd("set echo " + cfg.echo_info) cubit.cmd("set journal " + cfg.jou_info)
def createEllipseFull(v1,v2,v3): cubit.cmd("create curve vertex %d vertex %d vertex %d ellipse start angle 0 stop angle 360" % (v1,v2,v3)) ellipseID = cubit.get_last_id("curve") return ellipseID
import os import sys #Domain parameters Lx = 250 Ly = 200 depth = 50 Cx = Lx / 2 Cy = Ly / 2 mesh_size = 2.5 cubit.cmd('brick x ' + str(Lx) + ' y ' + str(Ly) + ' z ' + str(depth)) cubit.cmd('volume 1 move x ' + str(Lx / 2) + ' y ' + str(Ly / 2) + ' z ' + str(-depth / 2)) id_intern = cubit.get_last_id("volume") s = cubit.get_relatives("volume", id_intern, "surface") print s side_xmin = [] side_xmax = [] side_ymin = [] side_ymax = [] side_zmin = [] side_xmax.append(s[5]) side_xmin.append(s[3]) side_ymax.append(s[4]) side_ymin.append(s[2]) side_zmin.append(s[1]) surf_id = s[0] #meshing
(0.55 / 2 - 0.03 / 2) / np.tan(np.pi * venturi_angle / 180.0) + vane_height + 0.03 + 0.15) stage3_cut = dome_plane - ( (0.85 / 2 - 0.55 / 2) / np.tan(np.pi * venturi_angle / 180.0) + (0.55 / 2 - 0.03 / 2) / np.tan(np.pi * venturi_angle / 180.0) + vane_height + 0.03 + 0.15) # cubit.cmd('create curve arc radius .5 center location ' + str(p2 + 0.25) + ' 9.2125 0.000000 normal 1 0 0 start angle 0 stop angle 360') # last_id = cubit.get_last_id("curve") # cubit.cmd('webcut volume all with loop curve ' + str(last_id) + ' imprint merge') # cubit.cmd('delete curve ' + str(last_id)) cubit.cmd('create curve arc radius .5 center location ' + str(stage2_cut - 0.25) + ' 10.425 0.000000 normal 1 0 0 start angle 0 stop angle 360') last_id = cubit.get_last_id("curve") cubit.cmd('webcut volume all with loop curve ' + str(last_id) + ' imprint merge') cubit.cmd('delete curve ' + str(last_id)) cubit.cmd('create curve arc radius .5 center location ' + str(stage2_cut - 0.25) + ' 10.0492037 1.05621387 normal 1 0 0 start angle 0 stop angle 360') last_id = cubit.get_last_id("curve") cubit.cmd('webcut volume all with loop curve ' + str(last_id) + ' imprint merge') cubit.cmd('delete curve ' + str(last_id)) cubit.cmd('create curve arc radius .5 center location ' + str(stage3_cut - 0.25) + ' 8.00000 0.000000 normal 1 0 0 start angle 0 stop angle 360') last_id = cubit.get_last_id("curve") cubit.cmd('webcut volume all with loop curve ' + str(last_id) +
def createEllipse(v1,v2,v3): cubit.cmd("create curve vertex %d vertex %d vertex %d ellipse" % (v1,v2,v3)) ellipseID = cubit.get_last_id("curve") return ellipseID
def createCircleNormal2(cv,iv,fv,r,c): cubit.cmd("create curve arc center vertex %d %d %d radius %f normal curve %d" % (cv,iv,fv,r,c)) circleID = cubit.get_last_id("curve") return circleID