from abapy.indentation import IndentationMesh from matplotlib import pyplot as plt Na = 2 Nb = 3 l, ltot = 1., 2 mesh = IndentationMesh(Na, Nb, l) xe, ye, ze = mesh.get_edges() plt.figure() plt.gca().set_aspect('equal') plt.plot(xe, ye, 'r-') plt.plot(mesh.nodes.x, mesh.nodes.y, 'ob') bbox = mesh.nodes.boundingBox() plt.xlim(bbox[0]) plt.ylim(bbox[1]) plt.show()
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)
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. #plt.show() plt.savefig(workdir + simname + '_field.png')