def JDArr_List_2_np(ds): result=np.ndarray((ds.size(),len(ds.get(0)))) i=0 for d in iter_Iterable(ds): result[i]=d i+=1 return result;
def get_x_y(nodeList): x = deque() y = deque() for nd in ju.iter_Iterable(nodeList): x.append(nd.x) y.append(nd.y) return (x, y)
def _exact_value(tBeam,coords,val_type): fun_map={'stress':(tBeam.getStress,(None,),3),'strain':(tBeam.getStrain,(None,),3),'displacement':(tBeam.getDisplacement,(None,1),6)} (fun,args,numCol)=fun_map[val_type] result=np.ndarray((coords.size(),numCol)) i=0 for coord in ju.iter_Iterable(coords): result[i]=fun(coord.x,coord.y,*args) i+=1 return result
def get_mat_k(assemblier): mat=assemblier.mainMatrix k_size=get_k_size(assemblier) mat_k=np.ndarray((k_size,k_size)) for me in ju.iter_Iterable(mat): row=me.row() col=me.column() if me.row()<k_size and me.column()<k_size: val=me.get() mat_k[row,col]=val mat_k[col,row]=val return mat_k
def gen_net_path(itemList): pt_lnk = {} points = deque() for item in ju.iter_Iterable(itemList): if isinstance(item, ju.Triangle): tri = item pts = (_Point(tri.c1.x, tri.c1.y), _Point(tri.c2.x, tri.c2.y), _Point(tri.c3.x, tri.c3.y)) pts_len = 3; elif isinstance(item, ju.Quadrangle): quad = item pts = (_Point(quad.x1, quad.y1), _Point(quad.x2, quad.y2), _Point(quad.x3, quad.y3), _Point(quad.x4, quad.y4)) pts_len = 4; for i in xrange(pts_len): (p_start, p_end) = (pts[i], pts[(i + 1) % pts_len]) if p_start > p_end: t = p_end; p_end = p_start p_start = t if not p_start in pt_lnk: pt_lnk[p_start] = set() pt_lnk[p_start].add(p_end) for start_pt in pt_lnk: for end_pt in pt_lnk[start_pt]: points.extend((start_pt.x, start_pt.y)) points.extend((end_pt.x, end_pt.y)) vertices = np.array(points, dtype=np.double).reshape((len(points) / 2, 2)) codes = np.ndarray((len(points) / 2,), dtype=Path.code_type) codes[::2] = Path.MOVETO codes[1::2] = Path.LINETO return Path(vertices, codes)