def addCylinder2Mod(xc,zc,r,modd,sigCylinder):
# Get points for cylinder outline
cylinderPoints = getCylinderPoints(xc,zc,r)
mod = copy.copy(modd)
verts = []
codes = []
for ii in range(0,cylinderPoints.shape[0]):
verts.append(cylinderPoints[ii,:])
if(ii == 0):
codes.append(Path.MOVETO)
elif(ii == cylinderPoints.shape[0]-1):
codes.append(Path.CLOSEPOLY)
else:
codes.append(Path.LINETO)
path = Path(verts, codes)
CCLocs = mesh.gridCC
insideInd = np.where(path.contains_points(CCLocs))
# #Check selected cell centers by plotting
# # print insideInd
# fig = plt.figure()
# ax = fig.add_subplot(111)
# patch = patches.PathPatch(path, facecolor='none', lw=2)
# ax.add_patch(patch)
# plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
# ax.set_xlim(-40,40)
# ax.set_ylim(-35,0)
# plt.axes().set_aspect('equal')
# plt.show()
mod[insideInd] = sigCylinder
return mod
评论列表
文章目录