def plotGradBaCo(sTh,**kwargs): assert issiMeshElt(sTh), "First argument must be a siMeshElt object" scale=kwargs.get('scale', 10) Ba=sTh.barycenters() Normal=sTh.NormalFaces() Colors=selectColors(sTh.d+1) if sTh.dim==2: for i in range(sTh.d+1): plt.quiver(Ba[0],Ba[1],Normal[i,0,:],Normal[i,1,:],units='x',color=Colors[i],scale=scale) xlist = [] ylist = [] for k in range(sTh.nme): xlist.extend((Ba[0,k],sTh.q[sTh.me[i,k],0])) xlist.append(None) ylist.extend((Ba[1,k],sTh.q[sTh.me[i,k],1])) ylist.append(None) plt.plot(xlist,ylist,color=Colors[i],ls=':') elif sTh.dim==3: for i in range(sTh.d+1): plt.quiver(Ba[0],Ba[1],Ba[2],Normal[i,0,:],Normal[i,1,:],Normal[i,2,:],units='x',color=Colors[i],scale=scale) xlist = [];ylist = [];zlist =[] for k in range(sTh.nme): xlist.extend((Ba[0,k],sTh.q[sTh.me[i,k],0])) xlist.append(None) ylist.extend((Ba[1,k],sTh.q[sTh.me[i,k],1])) ylist.append(None) zlist.extend((Ba[2,k],sTh.q[sTh.me[i,k],2])) zlist.append(None) plt.plot3(xlist,ylist,zlist,color=Colors[i],ls=':')
def plotElementsNumber(sTh,**kwargs): assert issiMeshElt(sTh), "First argument must be a siMeshElt object" Ba=sTh.barycenters() fig = plt.gcf() ax = fig.axes[0] if sTh.dim==2: for k in range(sTh.nme): ax.annotate(str(k),(Ba[k,0],Ba[k,1]),verticalalignment='center', horizontalalignment='center',clip_on=True,**kwargs)
def plotmesh(sTh,**kwargs): assert issiMeshElt(sTh), "First argument must be a siMeshElt object" #kwargs['name']=kwargs.get('name', mesh_label(sTh) ) kwargs['color']=check_color(kwargs.pop('color', sTh.color)) z=kwargs.pop('z',None) if z is not None: kwargs['z']=getLocalValue(sTh,z) move=kwargs.pop('move',None) if move is not None: kwargs['move']=getLocalVector(sTh,move) return plt4sim.plotmesh(sTh.q,sTh.me,**kwargs)
def plotiso(sTh,u,**kwargs): assert issiMeshElt(sTh), "First argument must be a siMeshElt object" assert sTh.d==2 and sTh.dim==2 vmin=kwargs.get('vmin', min(u));kwargs['vmin']=vmin vmax=kwargs.get('vmax', max(u));kwargs['vmax']=vmax return plt4sim.plotiso(sTh.q,sTh.me,getLocalValue(sTh,u),**kwargs)
def plot(sTh,u,**kwargs): assert issiMeshElt(sTh), "First argument must be a siMeshElt object" return plt4sim.plot(sTh.q,sTh.me,getLocalValue(sTh,u),**kwargs)