def plot_model(self):
"""
Plot the mesh model, including bcs
"""
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
from matplotlib.collections import PatchCollection
fig = plt.figure()
ax = fig.add_subplot(111)
_x,_y = [],[]
patches = []
for k,elm in enumerate(self.get_elements()):
_x,_y,_ux,_uy = [],[],[],[]
for nd in elm.nodes:
if nd.fx != 0: self._draw_xforce(ax,nd.x,nd.y)
if nd.fy != 0: self._draw_yforce(ax,nd.x,nd.y)
if nd.ux == 0 and nd.uy == 0: self._draw_xyconstraint(ax,nd.x,nd.y)
_x.append(nd.x)
_y.append(nd.y)
polygon = Polygon(zip(_x,_y), True)
patches.append(polygon)
pc = PatchCollection(patches, color="#7CE7FF", edgecolor="k", alpha=0.4)
ax.add_collection(pc)
x0,x1,y0,y1 = self.rect_region()
ax.set_xlim(x0,x1)
ax.set_ylim(y0,y1)
ax.set_title("Model %s"%(self.name))
ax.set_aspect("equal")
评论列表
文章目录