Skip to content

Commit

Permalink
Merge pull request #20 from u-anurag/master
Browse files Browse the repository at this point in the history
Added option to select show node and element tags
  • Loading branch information
zhuminjie committed Apr 24, 2020
2 parents c727c7f + 4815c3a commit 2eaae17
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions openseespy/postprocessing/Get_Rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,41 @@

from openseespy.opensees import *

def plot_model():
def plot_model(*argv):
#Options to display node and element tags, THe following procedure is to keep the backward compatibility.
if len(argv)== 1:
if argv[0]=="nodes" or argv[0]=="Nodes" or argv[0]=="node" or argv[0]=="Node":
show_node_tags = 'yes'
show_element_tags = 'no'

elif argv[0]=="elements" or argv[0]=="Elements" or argv[0]=="element" or argv[0]=="Element":
show_node_tags = 'no'
show_element_tags = 'yes'

else:
print("Incorrect arguments; correct arguments are plot_model(nodes,elements)")
print("Setting show node tags and element tags as default")
show_node_tags = 'yes'
show_element_tags = 'yes'

elif len(argv)== 2:
if "nodes" or "Nodes" in argv:
show_node_tags = 'yes'
else:
pass

if "elements" or "Elements" in argv:
show_element_tags = 'yes'
else:
pass

else:
print("Setting show node tags and element tags as default")
show_node_tags = 'yes'
show_element_tags = 'yes'

nodeList = getNodeTags()
eleList = getEleTags()
show_node_tags = 'yes' # Check if you want to display the node numbers :: 'yes' or 'no'
show_element_tags = 'yes' # Check if you want to display the element numbers :: 'yes' or 'no'
offset = 0.05 # offset for text

ele_style = {'color':'black', 'linewidth':1, 'linestyle':'-'} # elements
Expand Down Expand Up @@ -477,21 +506,21 @@ def plotCubeSurf(NodeList):
def recordNodeDisp(filename = 'nodeDisp.txt'):
# This function is meant to be run before an analysis and saves the displacements of all nodes into filename.
# It can be used later in the plot_deformedshape function.
nodeList = getNodeTags()
if len(nodeCoord(nodeList[0])) == 2:
dofList = [1, 2]
if len(nodeCoord(nodeList[0])) == 3:
dofList = [1, 2, 3]
# recorder('Node', '-file', filename, '–time', '–node', *nodeList, '-dof', *dofList, 'disp')
recorder('Node', '-file', filename, '-time', '-closeOnWrite', '–node', *nodeList, '-dof', *dofList, 'disp')
nodeList = getNodeTags()
if len(nodeCoord(nodeList[0])) == 2:
dofList = [1, 2]
if len(nodeCoord(nodeList[0])) == 3:
dofList = [1, 2, 3]
# recorder('Node', '-file', filename, '–time', '–node', *nodeList, '-dof', *dofList, 'disp')
recorder('Node', '-file', filename, '-time', '-closeOnWrite', '–node', *nodeList, '-dof', *dofList, 'disp')

def plot_deformedshape(filename = 'nodeDisp.txt', tstep = -1, scale = 200):
# Expected input argv : filename contains the displacements of all nodes in the same order they are returned by getNodeTags().
# First column in filename is time.
# tstep is the number of the step of the analysis to be ploted (starting from 1),
# and scale is the scale factor for the deformed shape.

nodeList = getNodeTags()
nodeList = getNodeTags()
eleList = getEleTags()
nodeDispArray = np.loadtxt(filename)
if len(nodeDispArray[0, :]) == len(nodeList) * len(nodeCoord(nodeList[0])):
Expand Down

0 comments on commit 2eaae17

Please sign in to comment.