def prepare_equivalence_new(name_group='lateral'): length={} cmd="group 'tmpn' add edge in face in group "+name_group cubit.cmd(cmd) ge=cubit.get_id_from_name("tmpn") e1=cubit.get_group_edges(ge) lengthmin=1e9 for e in e1: lengthmin=min(lengthmin,cubit.get_mesh_edge_length(e)) length[e]=lengthmin*.5 cubit.cmd('delete group '+str(ge)) minvalue=min(length.values()) maxvalue=max(length.values()) # print 'min lentgh: ',minvalue,'max lentgh: ',maxvalue nbin= int((maxvalue/minvalue)/2.)+1 factor=(maxvalue-minvalue)/nbin dic_new={} for k in length.keys(): dic_new[k]=int((length[k]-minvalue)/factor) inv_length=invert_dict(dic_new) print inv_length.keys(),factor,minvalue ks=inv_length.keys() ks.sort() for k in range(0,len(inv_length.keys())-1): inv_length[ks[k]]=inv_length[ks[k]]+inv_length[ks[k+1]] return factor,minvalue,inv_length
def prepare_equivalence(nodes1,nodes2): cubit.cmd('set info off') cubit.cmd('set echo off') cubit.cmd('set journal off') length={} for ns in zip(nodes1,nodes2): cmd='group "tmpn" add edge in node '+' '.join(str(n) for n in ns ) cubit.cmd(cmd) ge=cubit.get_id_from_name("tmpn") e1=cubit.get_group_edges(ge) lengthmin=1e9 for e in e1: lengthmin=min(lengthmin,cubit.get_mesh_edge_length(e)) length[ns]=lengthmin*.5 cubit.cmd('delete group '+str(ge)) minvalue=min(length.values()) maxvalue=max(length.values()) print 'min lentgh: ',minvalue,'max lentgh: ',maxvalue nbin= int((maxvalue/minvalue)/2.)+1 factor=(maxvalue-minvalue)/nbin dic_new={} for k in length.keys(): dic_new[k]=int((length[k]-minvalue)/factor) inv_length=invert_dict(dic_new) print inv_length.keys(),factor,minvalue ks=inv_length.keys() ks.sort() for k in range(0,len(inv_length.keys())-1): inv_length[ks[k]]=inv_length[ks[k]]+inv_length[ks[k+1]] cubit.cmd('set info on') cubit.cmd('set echo on') cubit.cmd('set journal on') return factor,minvalue,inv_length
def prepare_equivalence(nodes1, nodes2): cubit.cmd('set info off') cubit.cmd('set echo off') cubit.cmd('set journal off') length = {} for ns in zip(nodes1, nodes2): cmd = 'group "tmpn" add edge in node ' + ' '.join(str(n) for n in ns) cubit.cmd(cmd) ge = cubit.get_id_from_name("tmpn") e1 = cubit.get_group_edges(ge) lengthmin = 1e9 for e in e1: lengthmin = min(lengthmin, cubit.get_mesh_edge_length(e)) length[ns] = lengthmin * .5 cubit.cmd('delete group ' + str(ge)) minvalue = min(length.values()) maxvalue = max(length.values()) print 'min lentgh: ', minvalue, 'max lentgh: ', maxvalue nbin = int((maxvalue / minvalue) / 2.) + 1 factor = (maxvalue - minvalue) / nbin dic_new = {} for k in length.keys(): dic_new[k] = int((length[k] - minvalue) / factor) inv_length = invert_dict(dic_new) print inv_length.keys(), factor, minvalue ks = inv_length.keys() ks.sort() for k in range(0, len(inv_length.keys()) - 1): inv_length[ks[k]] = inv_length[ks[k]] + inv_length[ks[k + 1]] cubit.cmd('set info on') cubit.cmd('set echo on') cubit.cmd('set journal on') return factor, minvalue, inv_length
def prepare_equivalence_4(nodes1, nodes2, nodes3, nodes4): cubit.cmd('set info off') cubit.cmd('set echo off') cubit.cmd('set journal off') length = {} nodes = [nodes1, nodes2, nodes3, nodes4] check = map(len, nodes) checked_nodes = [] for ind, iflag in enumerate(check): if iflag: checked_nodes = checked_nodes + nodes[ind] cmd = 'group "tmpn" add edge in node ' + ' '.join( str(n) for n in checked_nodes) cubit.cmd(cmd) ge = cubit.get_id_from_name("tmpn") e1 = cubit.get_group_edges(ge) lengthmin = 1e9 for e in e1: lengthmin = min(lengthmin, cubit.get_mesh_edge_length(e)) length[e] = lengthmin * .5 cubit.cmd('delete group ' + str(ge)) try: minvalue = min(length.values()) maxvalue = max(length.values()) except: try: print nodes print 'edges ', e1 except: pass minvalue = 10. maxvalue = 2000. print 'min lentgh: ', minvalue, 'max lentgh: ', maxvalue nbin = int((maxvalue / minvalue) / 2.) + 1 factor = (maxvalue - minvalue) / nbin dic_new = {} for k in length.keys(): dic_new[k] = int((length[k] - minvalue) / factor) inv_length = invert_dict(dic_new) print inv_length.keys(), factor, minvalue ks = inv_length.keys() ks.sort() for k in range(0, len(inv_length.keys()) - 1): inv_length[ks[k]] = inv_length[ks[k]] + inv_length[ks[k + 1]] cubit.cmd('set info on') cubit.cmd('set echo on') cubit.cmd('set journal on') return factor, minvalue, inv_length
def prepare_equivalence_4(nodes1,nodes2,nodes3,nodes4): cubit.cmd('set info off') cubit.cmd('set echo off') cubit.cmd('set journal off') length={} nodes=[nodes1,nodes2,nodes3,nodes4] check=map(len,nodes) checked_nodes=[] for ind,iflag in enumerate(check): if iflag: checked_nodes=checked_nodes+nodes[ind] cmd='group "tmpn" add edge in node '+' '.join(str(n) for n in checked_nodes ) cubit.cmd(cmd) ge=cubit.get_id_from_name("tmpn") e1=cubit.get_group_edges(ge) lengthmin=1e9 for e in e1: lengthmin=min(lengthmin,cubit.get_mesh_edge_length(e)) length[e]=lengthmin*.5 cubit.cmd('delete group '+str(ge)) try: minvalue=min(length.values()) maxvalue=max(length.values()) except: try: print nodes print 'edges ', e1 except: pass minvalue=10. maxvalue=2000. print 'min lentgh: ',minvalue,'max lentgh: ',maxvalue nbin= int((maxvalue/minvalue)/2.)+1 factor=(maxvalue-minvalue)/nbin dic_new={} for k in length.keys(): dic_new[k]=int((length[k]-minvalue)/factor) inv_length=invert_dict(dic_new) print inv_length.keys(),factor,minvalue ks=inv_length.keys() ks.sort() for k in range(0,len(inv_length.keys())-1): inv_length[ks[k]]=inv_length[ks[k]]+inv_length[ks[k+1]] cubit.cmd('set info on') cubit.cmd('set echo on') cubit.cmd('set journal on') return factor,minvalue,inv_length