def mesh_cpml(list_vol,remesh=True,refinement=None,top_surf=None,size=None): from utilities import list2str top_surf=list2str(top_surf) if remesh: cubit.cmd('reset vol all') cubit.cmf('set dev on') cubit.cmd('imprint vol all') cubit.cmd('merge vol all') cubit.cmd('vol all size '+str(size)) cubit.cmd('mesh vol all') try: for refdepth in refinement: cubit.cmd('refine surf '+top_surf+' numsplit 1 bias 1 depth '+str(refdepth)) except: print 'DEBUG: error in refinement cpml' xmin=xmin-size xmax=xmax+size ymin=ymin-size ymax=ymax+size zmin=zmin-size zmin=zmax-size txt="group 'vol_xmin' add vol in surf with X_coord < "+str(xmin) cubit.cmd(txt) txt="group 'vol_xmax' add vol in surf with X_coord > "+str(xmax) cubit.cmd(txt) txt="group 'vol_ymin' add vol in surf with Y_coord < "+str(ymin) cubit.cmd(txt) txt="group 'vol_ymax' add vol in surf with Y_coord > "+str(ymax) cubit.cmd(txt) txt="group 'vol_zmin' add vol in surf with Z_coord < "+str(zmin) cubit.cmd(txt)
def get_ordered_node_surf(lsurface, icurve): if not isinstance(lsurface, str): lsurf = list2str(lsurface) # if not isinstance(icurve, str): icurvestr = str(icurve) # initializes orient_nodes_surf = [] nodes_curve = [] # #get the nodes on a surface, I don't use the method get_surface_nodes since it has different behavior in cubit12.2 and cubit13.2+ k = cubit.get_id_from_name('sl') if k != 0: cubit.cmd('del group sl') else: print 'initializing group sl' cubit.cmd("group 'sl' add node in surf " + lsurf) group1 = cubit.get_id_from_name("sl") nodes_ls = list(cubit.get_group_nodes(group1)) nnode = len(nodes_ls) # #get the nodes on curves orient = [] k = cubit.get_id_from_name('n1') if k != 0: cubit.cmd('del group n1') else: print 'initializing group n1' cubit.cmd("group 'n1' add node in curve " + icurvestr) x = cubit.get_bounding_box('curve', icurve) # checks if anything to do if len(x) == 0: return nodes_curve, orient_nodes_surf # gets nodes if x[2] > x[5]: idx = 0 else: idx = 1 group1 = cubit.get_id_from_name("n1") nodes1 = list(cubit.get_group_nodes(group1)) for n in nodes1: v = cubit.get_nodal_coordinates(n) orient.append(v[idx]) result = zip(orient, nodes1) result.sort() nodes2 = [c[1] for c in result] for n in nodes2: try: nodes_ls.remove(n) except: pass orient_nodes_surf = orient_nodes_surf + nodes2 # while len(orient_nodes_surf) < nnode: cubit.cmd('del group n1') cubit.cmd("group 'n1' add node in edge in node " + str(nodes2).replace('[', ' ').replace(']', ' ')) group1 = cubit.get_id_from_name("n1") nodes1 = list(cubit.get_group_nodes(group1)) orient = [] nd = [] for n in nodes1: if n in nodes_ls: v = cubit.get_nodal_coordinates(n) orient.append(v[idx]) nd.append(n) result = zip(orient, nd) result.sort() nodes2 = [c[1] for c in result] for n in nodes2: try: nodes_ls.remove(n) except: pass orient_nodes_surf = orient_nodes_surf + nodes2 #get the vertical curve curve_vertical = [] for s in lsurface: lcs = cubit.get_relatives("surface", s, "curve") for l in lcs: x = cubit.get_bounding_box('curve', l) length = [(x[2], 1), (x[5], 2), (x[8], 3)] length.sort() if length[-1][1] == 3: curve_vertical.append(l) # kcurve = list2str(curve_vertical) k = cubit.get_id_from_name('curve_vertical') if k != 0: cubit.cmd('del group curve_vertical') else: print 'initializing group curve_vertical' cubit.cmd("group 'curve_vertical' add node in curve " + kcurve) group1 = cubit.get_id_from_name('curve_vertical') nodes_curve = list(cubit.get_group_nodes(group1)) for n in nodes_curve: try: orient_nodes_surf.remove(n) except: pass # return nodes_curve, orient_nodes_surf
def get_ordered_node_surf(lsurface,icurve): if not isinstance(lsurface,str): lsurf=list2str(lsurface) # if not isinstance(icurve,str): icurvestr=str(icurve) orient_nodes_surf=[] # #get the nodes on a surface, I don't use the method get_surface_nodes since it has different behavior in cubit12.2 and cubit13.2+ k=cubit.get_id_from_name('sl') if k!=0: cubit.cmd('del group sl') else: print 'initializing group sl' cubit.cmd("group 'sl' add node in surf "+lsurf) group1 = cubit.get_id_from_name("sl") nodes_ls =list(cubit.get_group_nodes(group1)) nnode=len(nodes_ls) # #get the nodes on curves orient=[] k=cubit.get_id_from_name('n1') if k!=0: cubit.cmd('del group n1') else: print 'initializing group n1' cubit.cmd("group 'n1' add node in curve "+icurvestr) x=cubit.get_bounding_box('curve', icurve) if x[2]>x[5]: idx=0 else: idx=1 group1 = cubit.get_id_from_name("n1") nodes1 = list(cubit.get_group_nodes(group1)) for n in nodes1: v = cubit.get_nodal_coordinates(n) orient.append(v[idx]) result=zip(orient,nodes1) result.sort() nodes2=[c[1] for c in result] for n in nodes2: try: nodes_ls.remove(n) except: pass orient_nodes_surf=orient_nodes_surf+nodes2 # while len(orient_nodes_surf) < nnode: cubit.cmd('del group n1') cubit.cmd("group 'n1' add node in edge in node "+str(nodes2).replace('[',' ').replace(']',' ')) group1 = cubit.get_id_from_name("n1") nodes1 = list(cubit.get_group_nodes(group1)) orient=[] nd=[] for n in nodes1: if n in nodes_ls: v = cubit.get_nodal_coordinates(n) orient.append(v[idx]) nd.append(n) result=zip(orient,nd) result.sort() nodes2=[c[1] for c in result] for n in nodes2: try: nodes_ls.remove(n) except: pass orient_nodes_surf=orient_nodes_surf+nodes2 #get the vertical curve curve_vertical=[] for s in lsurface: lcs=cubit.get_relatives("surface",s,"curve") for l in lcs: x=cubit.get_bounding_box('curve', l) length=[(x[2],1),(x[5],2),(x[8],3)] length.sort() if length[-1][1] == 3: curve_vertical.append(l) # kcurve=list2str(curve_vertical) k=cubit.get_id_from_name('curve_vertical') if k!=0: cubit.cmd('del group curve_vertical') else: print 'initializing group curve_vertical' cubit.cmd("group 'curve_vertical' add node in curve "+kcurve) group1 = cubit.get_id_from_name('curve_vertical') nodes_curve = list(cubit.get_group_nodes(group1)) for n in nodes_curve: try: orient_nodes_surf.remove(n) except: pass # return nodes_curve,orient_nodes_surf