Esempio n. 1
0
def build_block_side(surf_list, name, obj="surface", id_0=1):
    id_nodeset = cubit.get_next_nodeset_id()
    id_block = id_0
    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("]", " ")
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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 + "'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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 + "'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    else:
        txt1 = ""
        txt2 = "block " + str(id_block) + " name " + name + "_notsupported (only hex,face,edge,node)"
        try:
            cubit.cmd('comment "' + txt1 + '"')
            cubit.cmd('comment "' + txt2 + '"')
        except:
            pass
def build_block_side(surf_list,name,obj='surface',id_0=1):
    id_nodeset=cubit.get_next_nodeset_id()
    id_block=id_0
    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("]"," ")
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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+"'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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+"'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    else:
        txt1=''
        txt2="block "+str(id_block)+" name "+name+"_notsupported (only hex,face,edge,node)"
        try:
            cubit.cmd('comment "'+txt1+'"')
            cubit.cmd('comment "'+txt2+'"')
        except:
            pass
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
def build_block_side(surf_list, name, obj='surface', id_0=1):
    id_nodeset = cubit.get_next_nodeset_id()
    id_block = id_0
    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("]", " ")
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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 + "'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    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 + "'"
        cubit.cmd(txt1)
        cubit.cmd(txt2)
    else:
        txt1 = ''
        txt2 = "block " + str(
            id_block
        ) + " name " + name + "_notsupported (only hex,face,edge,node)"
        try:
            cubit.cmd('comment "' + txt1 + '"')
            cubit.cmd('comment "' + txt2 + '"')
        except:
            pass