Skip to content

Commit

Permalink
adding tempSurface = [None] to _plotCubeSurf() (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
u-anurag committed Jul 7, 2020
1 parent 60d7198 commit b846096
Showing 1 changed file with 50 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,77 +22,80 @@


def _plotCubeSurf(nodeCords, ax, fillSurface, eleStyle):
## This procedure is called by the plotCubeVol() command
aNode = nodeCords[0]
bNode = nodeCords[1]
cNode = nodeCords[2]
dNode = nodeCords[3]
## This procedure is called by the plotCubeVol() command
aNode = nodeCords[0]
bNode = nodeCords[1]
cNode = nodeCords[2]
dNode = nodeCords[3]

## Use arrays for less memory and fast code
surfXarray = np.array([[aNode[0], dNode[0]], [bNode[0], cNode[0]]])
surfYarray = np.array([[aNode[1], dNode[1]], [bNode[1], cNode[1]]])
surfZarray = np.array([[aNode[2], dNode[2]], [bNode[2], cNode[2]]])

if fillSurface == 'yes':
tempSurface = ax.plot_surface(surfXarray, surfYarray, surfZarray, edgecolor='k', color='g', alpha=.5)
## Use arrays for less memory and fast code
surfXarray = np.array([[aNode[0], dNode[0]], [bNode[0], cNode[0]]])
surfYarray = np.array([[aNode[1], dNode[1]], [bNode[1], cNode[1]]])
surfZarray = np.array([[aNode[2], dNode[2]], [bNode[2], cNode[2]]])

## Initialize varables for matplotlib objects
tempSurface = [None]

if fillSurface == 'yes':
tempSurface = ax.plot_surface(surfXarray, surfYarray, surfZarray, edgecolor='k', color='g', alpha=.5)

del aNode, bNode, cNode, dNode, surfXarray, surfYarray, surfZarray
del aNode, bNode, cNode, dNode, surfXarray, surfYarray, surfZarray

return tempSurface
return tempSurface


def _plotCubeVol(iNode, jNode, kNode, lNode, iiNode, jjNode, kkNode, llNode, ax, show_element_tags, element, eleStyle, fillSurface):
## procedure to render a cubic element, use eleStyle = "wire" for a wire frame, and "solid" for solid element lines.
## USe fillSurface = "yes" for color fill in the elements. fillSurface="no" for wireframe.

tempSurfaces = 6*[None]
tempTag = [None]
tempSurfaces = 6*[None]
tempTag = [None]

# 2D Planer four-node shell elements
# [iNode, jNode, kNode, lNode,iiNode, jjNode, kkNode, llNode] = [*nodesCords]
# 2D Planer four-node shell elements
# [iNode, jNode, kNode, lNode,iiNode, jjNode, kkNode, llNode] = [*nodesCords]

tempSurfaces[0] = _plotCubeSurf([iNode, jNode, kNode, lNode], ax, fillSurface, eleStyle)
tempSurfaces[1] = _plotCubeSurf([iNode, jNode, jjNode, iiNode], ax, fillSurface, eleStyle)
tempSurfaces[2] = _plotCubeSurf([iiNode, jjNode, kkNode, llNode], ax, fillSurface, eleStyle)
tempSurfaces[3] = _plotCubeSurf([lNode, kNode, kkNode, llNode], ax, fillSurface, eleStyle)
tempSurfaces[4] = _plotCubeSurf([jNode, kNode, kkNode, jjNode], ax, fillSurface, eleStyle)
tempSurfaces[5] = _plotCubeSurf([iNode, lNode, llNode, iiNode], ax, fillSurface, eleStyle)
tempSurfaces[0] = _plotCubeSurf([iNode, jNode, kNode, lNode], ax, fillSurface, eleStyle)
tempSurfaces[1] = _plotCubeSurf([iNode, jNode, jjNode, iiNode], ax, fillSurface, eleStyle)
tempSurfaces[2] = _plotCubeSurf([iiNode, jjNode, kkNode, llNode], ax, fillSurface, eleStyle)
tempSurfaces[3] = _plotCubeSurf([lNode, kNode, kkNode, llNode], ax, fillSurface, eleStyle)
tempSurfaces[4] = _plotCubeSurf([jNode, kNode, kkNode, jjNode], ax, fillSurface, eleStyle)
tempSurfaces[5] = _plotCubeSurf([iNode, lNode, llNode, iiNode], ax, fillSurface, eleStyle)

if show_element_tags == 'yes':
tempTag = ax.text((iNode[0]+jNode[0]+kNode[0]+lNode[0]+iiNode[0]+jjNode[0]+kkNode[0]+llNode[0])/8,
(iNode[1]+jNode[1]+kNode[1]+lNode[1]+iiNode[1]+jjNode[1]+kkNode[1]+llNode[1])/8,
(iNode[2]+jNode[2]+kNode[2]+lNode[2]+iiNode[2]+jjNode[2]+kkNode[2]+llNode[2])/8,
str(element), **ele_text_style) #label elements
if show_element_tags == 'yes':
tempTag = ax.text((iNode[0]+jNode[0]+kNode[0]+lNode[0]+iiNode[0]+jjNode[0]+kkNode[0]+llNode[0])/8,
(iNode[1]+jNode[1]+kNode[1]+lNode[1]+iiNode[1]+jjNode[1]+kkNode[1]+llNode[1])/8,
(iNode[2]+jNode[2]+kNode[2]+lNode[2]+iiNode[2]+jjNode[2]+kkNode[2]+llNode[2])/8,
str(element), **ele_text_style) #label elements

return tempSurfaces, tempTag
return tempSurfaces, tempTag


def _plotTri2D(iNode, jNode, kNode, ax, show_element_tags, element, eleStyle, fillSurface):
## procedure to render a 2D three node shell element. use eleStyle = "wire" for a wire frame, and "solid" for solid element lines.
## USe fillSurface = "yes" for color fill in the elements. fillSurface="no" for wireframe.

# Initialize varables for matplotlib objects
tempLines = [None]
tempSurface = [None]
tempTag = [None]
## Initialize varables for matplotlib objects
tempLines = [None]
tempSurface = [None]
tempTag = [None]

tempLines, = plt.plot((iNode[0], jNode[0], kNode[0], iNode[0]),
tempLines, = plt.plot((iNode[0], jNode[0], kNode[0], iNode[0]),
(iNode[1], jNode[1], kNode[1], iNode[1]), marker='')

# update style
if eleStyle == "wire":
plt.setp(tempLines,**WireEle_style)
else:
plt.setp(tempLines,**ele_style)
# update style
if eleStyle == "wire":
plt.setp(tempLines,**WireEle_style)
else:
plt.setp(tempLines,**ele_style)

if fillSurface == 'yes':
tempSurface = ax.fill(np.array([iNode[0], jNode[0], kNode[0]]),
np.array([iNode[1], jNode[1], kNode[1]]), color='g', alpha=.6)
if fillSurface == 'yes':
tempSurface = ax.fill(np.array([iNode[0], jNode[0], kNode[0]]),
np.array([iNode[1], jNode[1], kNode[1]]), color='g', alpha=.6)

if show_element_tags == 'yes':
tempTag = ax.text((iNode[0] + jNode[0] + kNode[0])*1.0/3, (iNode[1]+jNode[1]+kNode[1])*1.0/3,
str(element), **ele_text_style) #label elements
return tempLines, tempSurface, tempTag
if show_element_tags == 'yes':
tempTag = ax.text((iNode[0] + jNode[0] + kNode[0])*1.0/3, (iNode[1]+jNode[1]+kNode[1])*1.0/3,
str(element), **ele_text_style) #label elements
return tempLines, tempSurface, tempTag


def _plotQuad2D(iNode, jNode, kNode, lNode, ax, show_element_tags, element, eleStyle, fillSurface):
Expand Down

0 comments on commit b846096

Please sign in to comment.