def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get("parallel", True) closed = keys.get("closed", False) ip = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # if parallel: absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, bottom_surf, xmin, ymin, xmax, ymax = define_surf( ip=ip, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy ) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # elif closed: surf = define_absorbing_surf_sphere() v_list, name_list = define_block() build_block(v_list, name_list, id_0) entities = args[0] id_side = 1 for entity in entities: build_block_side(surf, entity + "_closedvol", obj=entity, id_0=id_side) id_side = id_side + 1
def create_blocks(self,mesh_entity,list_entity=None,): if mesh_entity =='surface': txt=' face in surface ' elif mesh_entity == 'curve': txt=' edge in curve ' elif mesh_entity == 'group': txt=' face in group ' if list_entity: if not isinstance(list_entity,list): list_entity=[list_entity] for entity in list_entity: iblock=cubit.get_next_block_id() command = "block "+str(iblock)+ txt +str(entity) cubit.cmd(command)
def create_blocks(self,mesh_entity,list_entity = None,): if mesh_entity =='surface': txt = ' face in surface ' elif mesh_entity == 'curve': txt = ' edge in curve ' elif mesh_entity == 'group': txt = ' face in group ' if list_entity: if not isinstance(list_entity,list): list_entity = [list_entity] for entity in list_entity: iblock = cubit.get_next_block_id() command = "block "+str(iblock)+ txt +str(entity) cubit.cmd(command)
def create_blocks(self, mesh_entity, list_entity=None): if mesh_entity == "surface": txt = " face in surface " elif mesh_entity == "curve": txt = " edge in curve " elif mesh_entity == "group": txt = " face in group " if list_entity: if not isinstance(list_entity, list): list_entity = [list_entity] for entity in list_entity: iblock = cubit.get_next_block_id() command = "block " + str(iblock) + txt + str(entity) cubit.cmd(command)
def build_block_side(surf_list, name, obj='surface'): try: cubit.cmd('comment') except: try: import cubit cubit.init([""]) except: print 'error importing cubit' import sys sys.exit() id_nodeset = cubit.get_next_nodeset_id() id_block = cubit.get_next_block_id() # creates command string if obj == 'hex': txt = 'hex in node in surface' txt1 = 'block ' + str(id_block) + ' ' + txt + ' ' + str( list(surf_list)) txt2 = "block " + str(id_block) + " name '" + name + "'" txt1 = txt1.replace("[", " ").replace("]", " ") elif obj == 'node': txt = obj + ' in surface' txt1 = 'nodeset ' + str(id_nodeset) + ' ' + txt + ' ' + str( list(surf_list)) txt1 = txt1.replace("[", " ").replace("]", " ") txt2 = "nodeset " + str(id_nodeset) + " name '" + name + "'" elif obj == 'face' or obj == 'edge': txt = obj + ' in surface' txt1 = 'block ' + str(id_block) + ' ' + txt + ' ' + str( list(surf_list)) txt1 = txt1.replace("[", " ").replace("]", " ") txt2 = "block " + str(id_block) + " name '" + name + "'" else: txt1 = '' # do not execute: block id might be wrong print "##block " + str( id_block ) + " name '" + name + "_notsupported (only hex,face,edge,node)'" txt2 = '' # executes commands print "# command: " + txt1 print "# command: " + txt2 cubit.cmd(txt1) cubit.cmd(txt2)
def build_block_side(surf_list,name,obj='surface'): try: cubit.cmd('comment') except: try: import cubit cubit.init([""]) except: print 'error importing cubit' import sys sys.exit() id_nodeset=cubit.get_next_nodeset_id() id_block=cubit.get_next_block_id() # creates command string if obj == 'hex': txt='hex in node in surface' txt1='block '+str(id_block)+ ' '+ txt +' '+str(list(surf_list)) txt2="block "+str(id_block)+" name '"+name+"'" txt1=txt1.replace("["," ").replace("]"," ") elif obj == 'node': txt=obj+' in surface' txt1= 'nodeset '+str(id_nodeset)+ ' '+ txt +' '+str(list(surf_list)) txt1 = txt1.replace("["," ").replace("]"," ") txt2 = "nodeset "+str(id_nodeset)+" name '"+name+"'" elif obj == 'face' or obj == 'edge': txt=obj+' in surface' txt1= 'block '+str(id_block)+ ' '+ txt +' '+str(list(surf_list)) txt1 = txt1.replace("["," ").replace("]"," ") txt2 = "block "+str(id_block)+" name '"+name+"'" else: txt1='' # do not execute: block id might be wrong print "##block "+str(id_block)+" name '"+name+"_notsupported (only hex,face,edge,node)'" txt2='' # executes commands print "# command: " + txt1 print "# command: " + txt2 cubit.cmd(txt1) cubit.cmd(txt2)
def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get('parallel', True) closed = keys.get('closed', False) ip = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # if parallel: absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, bottom_surf, xmin, ymin, xmax, ymax = define_surf( ip=ip, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # elif closed: surf = define_absorbing_surf_sphere() v_list, name_list = define_block() build_block(v_list, name_list, id_0) entities = args[0] id_side = 1 for entity in entities: build_block_side(surf, entity + '_closedvol', obj=entity, id_0=id_side) id_side = id_side + 1
def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get('parallel', True) closed = keys.get('closed', False) ip = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # if parallel: absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, bottom_surf, xmin, ymin, xmax, ymax = define_surf( ip=ip, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # entities entities = args[0] print entities for entity in entities: print "##entity: " + str(entity) # block for free surface (w/ topography) #print '## topo surface block: ' + str(topo) if len(top_surf) == 0: print "" print "no topo surface found, please create block face_topo manually..." print "" else: build_block_side(top_surf, entity + '_topo', obj=entity, id_0=1001) # model has parallel sides (e.g. a block model ) # xmin - blocks if len(xmin) == 0: print "" print "no abs_xmin surface found, please create block manually..." print "" else: build_block_side(xmin, entity + '_abs_xmin', obj=entity, id_0=1003) # xmax - blocks if len(xmax) == 0: print "" print "no abs_xmax surface found, please create block manually..." print "" else: build_block_side(xmax, entity + '_abs_xmax', obj=entity, id_0=1005) # ymin - blocks if len(ymin) == 0: print "" print "no abs_xmin surface found, please create block manually..." print "" else: build_block_side(ymin, entity + '_abs_ymin', obj=entity, id_0=1004) # ymax - blocks if len(ymax) == 0: print "" print "no abs_ymax surface found, please create block manually..." print "" else: build_block_side(ymax, entity + '_abs_ymax', obj=entity, id_0=1006) # bottom - blocks if len(bottom_surf) == 0: print "" print "no abs_bottom surface found, please create block manually..." print "" else: build_block_side(bottom_surf, entity + '_abs_bottom', obj=entity, id_0=1002) # block for all sides together # NOTE: # this might fail in some CUBIT versions, when elements are already # assigned to other blocks #cubit.cmd('set duplicate block elements on') #try: # build_block_side(absorbing_surf,entity+'_abs',obj=entity,id_0=2001) #except: # print "no combined surface with all sides created" elif closed: print "##closed region" surf = define_absorbing_surf_sphere() v_list, name_list = define_block() build_block(v_list, name_list, id_0) # entities entities = args[0] id_side = 1001 print entities for entity in entities: build_block_side(surf, entity + '_closedvol', obj=entity, id_0=id_side) id_side = id_side + 1
def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get('parallel', True) closed = keys.get('closed', False) ip = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # if parallel: absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, \ bottom_surf, xmin, ymin, xmax, ymax = \ define_surf(ip=ip, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() print 'define block', v_list, name_list build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # entities entities = ['face'] if type(args) == list: if len(args) > 0: entities = args[0] print entities for entity in entities: print "##entity: " + str(entity) # block for free surface (w/ topography) # print '## topo surface block: ' + str(topo) if len(top_surf) == 0: print "" print "no topo surface found,\ please create block face_topo manually..." print "" else: build_block_side(top_surf, entity + '_topo', obj=entity, id_0=1001) # model has parallel sides (e.g. a block model ) # xmin - blocks if len(xmin) == 0: print "" print "0 abs_xmin surface found, please create block manually" print "" else: build_block_side(xmin, entity + '_abs_xmin', obj=entity, id_0=1003) # xmax - blocks if len(xmax) == 0: print "" print "0 abs_xmax surface found, please create block manually" print "" else: build_block_side(xmax, entity + '_abs_xmax', obj=entity, id_0=1005) # ymin - blocks if len(ymin) == 0: print "" print "0 abs_xmin surface found, please create block manually" print "" else: build_block_side(ymin, entity + '_abs_ymin', obj=entity, id_0=1004) # ymax - blocks if len(ymax) == 0: print "" print "0 abs_ymax surface found, please create block manually" print "" else: build_block_side(ymax, entity + '_abs_ymax', obj=entity, id_0=1006) # bottom - blocks if len(bottom_surf) == 0: print "" print "0 abs_bottom surf found, please create block manually" print "" else: build_block_side(bottom_surf, entity + '_abs_bottom', obj=entity, id_0=1002) elif closed: print "##closed region not ready"
def define_bc(*args,**keys): id_0=1 # # parallel=keys.get('parallel',True) closed=keys.get('closed',False) ip=keys.get("iproc",0) cpuxmin=keys.get("cpuxmin",0) cpuymin=keys.get("cpuymin",0) cpux=keys.get("cpux",1) cpuy=keys.get("cpuy",1) cpuxmax=keys.get("cpuxmax",cpux) cpuymax=keys.get("cpuymax",cpuy) optionsea=keys.get("optionsea",False) # if parallel: absorbing_surf,abs_xmin,abs_xmax,abs_ymin,abs_ymax,top_surf,bottom_surf,xmin,ymin,xmax,ymax=define_surf(ip=ip,cpuxmin=cpuxmin,cpuxmax=cpuxmax,cpuymin=cpuymin,cpuymax=cpuymax,cpux=cpux,cpuy=cpuy) id_0=cubit.get_next_block_id() v_list,name_list=define_block() build_block(v_list,name_list,id_0,top_surf,optionsea=optionsea) # entities if type(args)==list: entities=args[0] else: entities=['face'] print entities for entity in entities: print "##entity: "+str(entity) # block for free surface (w/ topography) #print '## topo surface block: ' + str(topo) if len(top_surf) == 0: print "" print "no topo surface found, please create block face_topo manually..." print "" else: build_block_side(top_surf,entity+'_topo',obj=entity,id_0=1001) # model has parallel sides (e.g. a block model ) # xmin - blocks if len(xmin) == 0: print "" print "no abs_xmin surface found, please create block manually..." print "" else: build_block_side(xmin,entity+'_abs_xmin',obj=entity,id_0=1003) # xmax - blocks if len(xmax) == 0: print "" print "no abs_xmax surface found, please create block manually..." print "" else: build_block_side(xmax,entity+'_abs_xmax',obj=entity,id_0=1005) # ymin - blocks if len(ymin) == 0: print "" print "no abs_xmin surface found, please create block manually..." print "" else: build_block_side(ymin,entity+'_abs_ymin',obj=entity,id_0=1004) # ymax - blocks if len(ymax) == 0: print "" print "no abs_ymax surface found, please create block manually..." print "" else: build_block_side(ymax,entity+'_abs_ymax',obj=entity,id_0=1006) # bottom - blocks if len(bottom_surf) == 0: print "" print "no abs_bottom surface found, please create block manually..." print "" else: build_block_side(bottom_surf,entity+'_abs_bottom',obj=entity,id_0=1002) # block for all sides together # NOTE: # this might fail in some CUBIT versions, when elements are already # assigned to other blocks #cubit.cmd('set duplicate block elements on') #try: # build_block_side(absorbing_surf,entity+'_abs',obj=entity,id_0=2001) #except: # print "no combined surface with all sides created" elif closed: print "##closed region" surf=define_absorbing_surf_sphere() v_list,name_list=define_block() build_block(v_list,name_list,id_0) # entities entities=args[0] id_side=1001 print entities for entity in entities: build_block_side(surf,entity+'_closedvol',obj=entity,id_0=id_side) id_side=id_side+1
def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get('parallel', True) closed = keys.get('closed', False) iproc = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # boundary condition surfaces detection if parallel: # parallel sides # (for example box-like models with parallel sides on xmin/max, ymin/max, bottom/top) absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, \ bottom_surf, xmin, ymin, xmax, ymax = \ define_surf(iproc=iproc, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() print('define block', v_list, name_list) build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # entities entities = ['face'] if type(args) == list: if len(args) > 0: entities = args[0] print(entities) for entity in entities: print("##entity: " + str(entity)) # block for free surface (w/ topography) # print('## topo surface block: ' + str(topo)) if len(top_surf) == 0: print("") print("no topo surface found,\ please create block face_topo manually...") print("") else: build_block_side(top_surf, entity + '_topo', obj=entity, id_0=1001) # model has parallel sides (e.g. a block model ) # xmin - blocks if len(xmin) == 0: print("") print("0 abs_xmin surface found, please create block manually") print("") else: build_block_side(xmin, entity + '_abs_xmin', obj=entity, id_0=1003) # xmax - blocks if len(xmax) == 0: print("") print("0 abs_xmax surface found, please create block manually") print("") else: build_block_side(xmax, entity + '_abs_xmax', obj=entity, id_0=1005) # ymin - blocks if len(ymin) == 0: print("") print("0 abs_xmin surface found, please create block manually") print("") else: build_block_side(ymin, entity + '_abs_ymin', obj=entity, id_0=1004) # ymax - blocks if len(ymax) == 0: print("") print("0 abs_ymax surface found, please create block manually") print("") else: build_block_side(ymax, entity + '_abs_ymax', obj=entity, id_0=1006) # bottom - blocks if len(bottom_surf) == 0: print("") print("0 abs_bottom surf found, please create block manually") print("") else: build_block_side(bottom_surf, entity + '_abs_bottom', obj=entity, id_0=1002) elif closed: # closed boundary surfaces # (for example sphere or cylinder-like models) print("##closed region not ready") # surf = define_absorbing_surf_sphere() # v_list, name_list = define_block() # build_block(v_list, name_list, id_0) # # entities # entities = args[0] # id_side = 1001 # print(entities) # for entity in entities: # build_block_side(surf, entity + '_closedvol', # obj=entity, id_0=id_side) # id_side = id_side + 1 else: # case should not happen, parallel is default print("## no boundary surfaces detection") print( "## Please select option parallel=True for parallel boundary surfaces detection" )
def define_bc(*args, **keys): id_0 = 1 # # parallel = keys.get('parallel', True) closed = keys.get('closed', False) ip = keys.get("iproc", 0) cpuxmin = keys.get("cpuxmin", 0) cpuymin = keys.get("cpuymin", 0) cpux = keys.get("cpux", 1) cpuy = keys.get("cpuy", 1) cpuxmax = keys.get("cpuxmax", cpux) cpuymax = keys.get("cpuymax", cpuy) optionsea = keys.get("optionsea", False) # if parallel: absorbing_surf, abs_xmin, abs_xmax, abs_ymin, abs_ymax, top_surf, \ bottom_surf, xmin, ymin, xmax, ymax = \ define_surf(ip=ip, cpuxmin=cpuxmin, cpuxmax=cpuxmax, cpuymin=cpuymin, cpuymax=cpuymax, cpux=cpux, cpuy=cpuy) id_0 = cubit.get_next_block_id() v_list, name_list = define_block() build_block(v_list, name_list, id_0, top_surf, optionsea=optionsea) # entities entities = ['face'] if type(args) == list: if len(args) > 0: entities = args[0] print entities for entity in entities: print "##entity: " + str(entity) # block for free surface (w/ topography) # print '## topo surface block: ' + str(topo) if len(top_surf) == 0: print "" print "no topo surface found,\ please create block face_topo manually..." print "" else: build_block_side(top_surf, entity + '_topo', obj=entity, id_0=1001) # model has parallel sides (e.g. a block model ) # xmin - blocks if len(xmin) == 0: print "" print "0 abs_xmin surface found, please create block manually" print "" else: build_block_side(xmin, entity + '_abs_xmin', obj=entity, id_0=1003) # xmax - blocks if len(xmax) == 0: print "" print "0 abs_xmax surface found, please create block manually" print "" else: build_block_side(xmax, entity + '_abs_xmax', obj=entity, id_0=1005) # ymin - blocks if len(ymin) == 0: print "" print "0 abs_xmin surface found, please create block manually" print "" else: build_block_side(ymin, entity + '_abs_ymin', obj=entity, id_0=1004) # ymax - blocks if len(ymax) == 0: print "" print "0 abs_ymax surface found, please create block manually" print "" else: build_block_side(ymax, entity + '_abs_ymax', obj=entity, id_0=1006) # bottom - blocks if len(bottom_surf) == 0: print "" print "0 abs_bottom surf found, please create block manually" print "" else: build_block_side(bottom_surf, entity + '_abs_bottom', obj=entity, id_0=1002) elif closed: print "##closed region" surf = define_absorbing_surf_sphere() v_list, name_list = define_block() build_block(v_list, name_list, id_0) # entities entities = args[0] id_side = 1001 print entities for entity in entities: build_block_side(surf, entity + '_closedvol', obj=entity, id_0=id_side) id_side = id_side + 1