我正在开发一个二维平面有限元工具。其中一个特点是能够直观地看到某个物体上的应力。在
此工具使用以下数据创建四边形网格:节点:网格中每个节点的numpy数组[[x1 y1], [x2 y2], etc]->;x和{}坐标
元素:numpy array[[1 2 3 4], [2 3 5 6]]->;数组的每一行对应于网格中一个特定元素的4个点。
我能够实现一种绘制网格的方法:import matplotlib.pyplot as plt
import matplotlib.collections
import matplotlib.cm as cm
import numpy as np
def showMeshPlot(nodes, elements):
y = nodes[:,0]
z = nodes[:,1]
#https://stackoverflow.com/questions/49640311/matplotlib-unstructered-quadrilaterals-instead-of-triangles
def quatplot(y,z, quatrangles, ax=None, **kwargs):
if not ax: ax=plt.gca()
yz = np.c_[y,z]
verts= yz[quatrangles]
pc = matplotlib.collections.PolyCollection(verts, **kwargs)
ax.add_collection(pc)
ax.autoscale()
plt.figure()
plt.gca().set_aspect(