smin= min( min(stress.data), min(ind_stress.data)) #levels = [(n+1)/float(Nlevels)*smax for n in xrange(Nlevels)] levels = np.linspace(smin, smax, Nlevels) field_flag = r'$\sigma_{eq}$' disp = fo['U'][step2plot] ind_disp = fo['Uind'][step2plot] indenter.apply_displacement(ind_disp) # Applies the displacement to the indenter. #plt.plot(xbi,ybi,'k-') mesh.nodes.apply_displacement(disp) # This Nodes class method allows to deform a Nodes instance (and the Mesh instance it's nested in by the way) using a VectorFieldOutput. This allows very easy mesh tuning and deformed shape ploting. xlim, ylim, zlim = mesh.nodes.boundingBox() # This little method allows nicer ploting producing a bounding box with a little gap around the mesh. This avoids the very tight boxes pyplot tends to use which cut thick lines on the border of the mesh. xmin, xmax = 0., 2. ymin, ymax = -2., 2. plt.xlim([xmin, xmax]) plt.ylim([ymin, ymax]) x, y, z, tri = mesh.dump2triplot() # This method translates the whole mesh in matplotlib.pyplot.triplot syntax: x coords, y coords, (z coords useless here but can be nice for perspective effects) and label less connectivity. xi, yi, zi, trii = indenter.mesh.dump2triplot() xe, ye, ze = mesh.get_edges(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax) xb, yb, zb = mesh.get_border(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax) xei, yei, zei = indenter.mesh.get_edges(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax) # Gives us a wireframe indenter representation. xbi, ybi, zbi = indenter.mesh.get_border(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax) # Gives us the border of the indenter. plt.plot(xe,ye,'-k', linewidth = 0.5) # Mesh ploting. plt.plot(xb,yb,'-k', linewidth = 1.) # Sample border ploting. plt.plot(xei,yei,'-k', linewidth = 0.5) # Mesh ploting. plt.plot(xbi,ybi,'-k', linewidth = 1.) # Sample border ploting. grad = plt.tricontourf(x, y, tri, stress.data, levels) # Gradiant plot, Nlevels specifies the number of levels. plt.tricontourf(xi,yi,trii, ind_stress.data, levels) #plt.tricontour(xi,yi,trii, ind_stress.data, levels, colors = 'black') cbar = plt.colorbar(grad) cbar.ax.set_ylabel(field_flag, fontsize=20) #plt.tricontour(x, y, tri, stress.data, levels, colors = 'black') # Isovalue plot which make gradiant plot clearer in my (humble) opinion.
disp = fo['U'][step2plot] ind_disp = fo['Uind'][step2plot] indenter.apply_displacement( ind_disp) # Applies the displacement to the indenter. #plt.plot(xbi,ybi,'k-') mesh.nodes.apply_displacement( disp ) # This Nodes class method allows to deform a Nodes instance (and the Mesh instance it's nested in by the way) using a VectorFieldOutput. This allows very easy mesh tuning and deformed shape ploting. xlim, ylim, zlim = mesh.nodes.boundingBox( ) # This little method allows nicer ploting producing a bounding box with a little gap around the mesh. This avoids the very tight boxes pyplot tends to use which cut thick lines on the border of the mesh. xmin, xmax = 0., 2. ymin, ymax = -2., 2. plt.xlim([xmin, xmax]) plt.ylim([ymin, ymax]) x, y, z, tri = mesh.dump2triplot( ) # This method translates the whole mesh in matplotlib.pyplot.triplot syntax: x coords, y coords, (z coords useless here but can be nice for perspective effects) and label less connectivity. xi, yi, zi, trii = indenter.mesh.dump2triplot() xe, ye, ze = mesh.get_edges(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) xb, yb, zb = mesh.get_border(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) xei, yei, zei = indenter.mesh.get_edges( xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) # Gives us a wireframe indenter representation. xbi, ybi, zbi = indenter.mesh.get_border( xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) # Gives us the border of the indenter. plt.plot(xe, ye, '-k', linewidth=0.5) # Mesh ploting. plt.plot(xb, yb, '-k', linewidth=1.) # Sample border ploting. plt.plot(xei, yei, '-k', linewidth=0.5) # Mesh ploting. plt.plot(xbi, ybi, '-k', linewidth=1.) # Sample border ploting. grad = plt.tricontourf( x, y, tri, stress.data,
disp = fo['U'][step2plot] ind_disp = fo['Uind'][step2plot] # Applies the displacement to the indenter. indenter.apply_displacement(ind_disp) # plt.plot(xbi,ybi,'k-') # This Nodes class method allows to deform a Nodes instance (and the Mesh instance it's nested in by the way) using a VectorFieldOutput. This allows very easy mesh tuning and deformed shape ploting. mesh.nodes.apply_displacement(disp) # This little method allows nicer ploting producing a bounding box with a little gap around the mesh. This avoids the very tight boxes pyplot tends to use which cut thick lines on the border of the mesh. xlim, ylim, zlim = mesh.nodes.boundingBox() xmin, xmax = 0., 2. ymin, ymax = -2., 2. plt.xlim([xmin, xmax]) plt.ylim([ymin, ymax]) # This method translates the whole mesh in matplotlib.pyplot.triplot syntax: x coords, y coords, (z coords useless here but can be nice for perspective effects) and label less connectivity. x, y, z, tri = mesh.dump2triplot() xi, yi, zi, trii = indenter.mesh.dump2triplot() xe, ye, ze = mesh.get_edges(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) xb, yb, zb = mesh.get_border(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) # Gives us a wireframe indenter representation. xei, yei, zei = indenter.mesh.get_edges(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) # Gives us the border of the indenter. xbi, ybi, zbi = indenter.mesh.get_border(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) plt.plot(xe, ye, '-k', linewidth=0.5) # Mesh ploting. plt.plot(xb, yb, '-k', linewidth=1.) # Sample border ploting.