def drawElementValues(self, figElementValues): """Draw element values in provided figure""" cfv.figure(figElementValues.nr) cfv.clf() cfv.drawElementValues(self.results.elForces, self.mesh.coords, self.mesh.edof, self.rect.dofsPerNode, self.rect.elementType, self.results.a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Effective Stress", magnfac=1)
def drawElementValues(self, figElementValues): """Draws element values in specified figure""" cfv.figure(figElementValues.nr) cfv.clf() cfv.drawElementValues(self.vonMises, self.coords, self.edof, self.mesh.dofsPerNode, self.mesh.elType, self.a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Example 06 effective stress")
def showElementValues(self): if self.calcDone == True: self.elValueFig = cfv.figure(self.elValueFig) cfv.drawElementValues(self.outputData.vonMises, self.outputData.coords, self.outputData.edof, self.outputData.dofsPerNode, self.outputData.elType, self.outputData.asolve, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Effective Stress", magnfac=25.0) cfv.colorBar().SetLabel("Effective stress") cfu.info("Done drawing...")
cfv.figure() cfv.drawMesh(coords=coords, edof=edof, dofsPerNode=mesh.dofsPerNode, elType=mesh.elType, filled=True, title="Example 01") # ----- Draw results cfv.figure() cfv.drawElementValues(vonMises, coords, edof, mesh.dofsPerNode, mesh.elType, a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Example 06 effective stress") cfv.figure() cfv.drawDisplacements(a, coords, edof, mesh.dofsPerNode, mesh.elType, doDrawUndisplacedMesh=True, title="Example 06", magnfac=10.0)
es, et = planqs(ex[i,:], ey[i,:], ep, D, ed[i,:]) # Calc and append effective stress to list. vonMises.append( math.sqrt( pow(es[0],2) - es[0]*es[1] + pow(es[1],2) + 3*es[2] ) ) ## es: [sigx sigy tauxy] # ---- Visualise results ---------------------------------------------------- print("Visualising...") cfv.drawGeometry(g, drawPoints=False, labelCurves=True) vv.figure() cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Example 06 effective stress") vv.figure() cfv.drawDisplacements(a, coords, edof, dofsPerNode, elType, doDrawUndisplacedMesh=True, title="Example 06") # Make use of attribute 'nodesOnCurve' in GmshMesher to draw some arrows on # the right hand side of the mesh: rightSideNodes = set() # 4 and 5 are the IDs of the curves where we applied the forces. for curveID in [4,5]: # Get the nodes, without duplicates.
rect.elementType, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.drawDisplacements(results.a, mesh.coords, mesh.edof, rect.dofsPerNode, rect.elementType, doDrawUndisplacedMesh=False, title="Displacements", magnfac=1) cfv.figure() cfv.drawElementValues(results.elForces, mesh.coords, mesh.edof, rect.dofsPerNode, rect.elementType, results.a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Effective Stress", magnfac=1) #cfv.colorBar().SetLabel("Effective stress") cfu.info("Done drawing...") cfv.showAndWait()
ed = cfc.extractEldisp(edof,a) maxFlow = [] for i in range(edof.shape[0]): es, et, eci = cfc.flw2i4s(ex[i,:], ey[i,:], ep, D, ed[i,:]) maxFlow.append( math.sqrt( math.pow(es[0,0],2) + math.pow(es[0,1],2)) ) # ------ Draw results ------------ cfv.figure() cfv.drawGeometry(g, title="Geometry") cfv.figure() cfv.drawElementValues(maxFlow, coords, edof, dofsPerNode, elType, None, doDrawMesh=False, title="Max flows") cfv.figure() cfv.drawMesh(coords, edof, dofsPerNode, elType, filled=True, title="Mesh") cfv.figure() cfv.drawNodalValues(a, coords, edof, dofsPerNode, elType, doDrawMesh=False, title="Nodal values") cfv.colorBar().SetLabel("Flow") print("Done drawing...") cfv.showAndWait()
elprop[elementmarkers[i]][1], ed[i,:]) vonMises.append( np.math.sqrt( pow(es[0],2) - es[0]*es[1] + pow(es[1],2) + 3*pow(es[2],2) ) ) # ---- Visualise results ---------------------------------------------------- print("Drawing results...") cfv.figure() cfv.drawGeometry(g, title="Geometry") cfv.figure() cfv.drawMesh(coords=coords, edof=edof, dofsPerNode=dofsPerNode, elType=elType, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.drawDisplacements(a, coords, edof, dofsPerNode, elType, doDrawUndisplacedMesh=False, title="Displacements", magnfac=25.0) cfv.figure() cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Effective Stress", magnfac=25.0) cfv.colorBar().SetLabel("Effective stress") print("Done drawing...") cfv.showAndWait()
def show(self): # ------ Shows the geometry geometry = self.outputData.geometry a = self.outputData.a vonMises = self.outputData.stress coords = self.outputData.coords edof = self.outputData.edof dofsPerNode = self.outputData.mp[1] elType = self.outputData.mp[0] meshGen = self.outputData.meshGen stats = self.outputData.statistics fp = self.inputData.fp bp = self.inputData.bp w = stats[4][0] h = stats[4][1] units = self.inputData.units # Create the figure print("Visualizing...") cfv.close_all() if (self.geomFig): cfv.figure() cfv.drawGeometry(geometry, title="Geometry", drawPoints=False, labelCurves=True) if (self.elValueFig): cfv.figure() cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, doDrawMesh=self.meshFig, doDrawUndisplacedMesh=False, title="Effective (Von Mises) Stress (Pa)") # ------ Add extra text node_x = [ coords[int((edof[stats[0][0]][0] - 1) / 2), 0] + a[edof[stats[0][0]][0] - 1, 0], coords[int( (edof[stats[0][0]][2] - 1) / 2), 0] + a[edof[stats[0][0]][2] - 1, 0], coords[int( (edof[stats[0][0]][4] - 1) / 2), 0] + a[edof[stats[0][0]][4] - 1, 0] ] node_y = [ coords[int((edof[stats[0][0]][0] - 1) / 2), 1] + a[edof[stats[0][0]][1] - 1, 0], coords[int( (edof[stats[0][0]][2] - 1) / 2), 1] + a[edof[stats[0][0]][3] - 1, 0], coords[int( (edof[stats[0][0]][4] - 1) / 2), 1] + a[edof[stats[0][0]][5] - 1, 0] ] node_centroid = [sum(node_x) / 3, sum(node_y) / 3] cfv.addText("Max Stress: {0:.2f} MPa".format(stats[0][1] / 1e6), (stats[3][0] + 0.725 * w, stats[3][1] + 0.925 * h), fontSize=15, color='w') cfv.vv.plot([stats[3][0] + 0.715 * w, node_centroid[0]], [stats[3][1] + 0.925 * h, node_centroid[1]], lc='w') if (self.nodeValueFig): cfv.figure() cfv.drawDisplacements(a, coords, edof, dofsPerNode, elType, doDrawUndisplacedMesh=True, title="Displacements (m)") # Add markers symbols = { "rightarrow": "\u2192", "leftarrow": "\u2190", "uparrow": "\u2191", "downarrow": "\u2193", "nearrow": "\u2197", "nwarrow": "\u2196", "swarrow": "\u2199", "searrow": "\u2198", "fixed": "\u2215" } forceNodes = set() bcNodes = set() for j in range(len(fp[0])): for curveID in stats[2][fp[0][j]]: forceNodes = forceNodes.union( set(meshGen.nodesOnCurve[curveID])) for i in forceNodes: x = coords[i, 0] + a[i * 2, 0] # Position of node with displacements y = coords[i, 1] + a[i * 2 + 1, 0] cfv.addText(symbols["rightarrow"], (x, y), angle=fp[2][j], fontSize=20, color='g') for curveID in stats[2][bp[0][j]]: bcNodes = bcNodes.union(set(meshGen.nodesOnCurve[curveID])) for i in bcNodes: x = coords[i, 0] + a[i * 2, 0] # Position of node with displacements y = coords[i, 1] + a[i * 2 + 1, 0] cfv.addText(symbols["fixed"], (x, y), fontSize=15, color='r') # --- Add additional text cfv.addText("Forces Applied: {0:6.2f} kN/m".format( self.inputData.fp[1][0] * U2SI[units][1] / 1e3), (stats[3][0] + 0.725 * w, stats[3][1] + 0.925 * h), fontSize=15, color='g') cfv.addText("Boundary Condition: {0:6.2f}m displacement".format( self.inputData.bp[1][0] * U2SI[units][0]), (stats[3][0] + 0.625 * w, stats[3][1] + 0.95 * h), fontSize=15, color='r') node_x = coords[int((edof[stats[1][0][0]][stats[1][0][1]] - 1) / 2), 0] +\ + a[edof[stats[1][0][0]][stats[1][0][1]] - 1, 0] node_y = coords[int((edof[stats[1][0][0]][stats[1][0][1]] - 1) / 2), 1] +\ + a[edof[stats[1][0][0]][stats[1][0][1]+1] - 1, 0] cfv.addText("Max Displacement: {0:6.2f} mm".format(stats[1][1] * 1e3), (stats[3][0] + 0.725 * w, stats[3][1] + 0.9 * h), fontSize=15, color='w') cfv.vv.plot([stats[3][0] + 0.715 * w, node_x], [stats[3][1] + 0.9 * h, node_y], lc='w')
elType=elType, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.drawDisplacements(a, coords, edof, dofsPerNode, elType, doDrawUndisplacedMesh=False, title="Displacements", magnfac=25.0) cfv.figure() cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Effective Stress", magnfac=25.0) cfv.colorBar().SetLabel("Effective stress") cfu.info("Done drawing...") cfv.showAndWait()
ed = cfc.extractEldisp(edof, a) maxFlow = [] # empty list to store flow # calculating element force for i in range(edof.shape[0]): es, et, eci = cfc.flw2i4s(ex[i, :], ey[i, :], ep, D, ed[i, :]) maxFlow.append(np.sqrt(pow(es[0, 0], 2) + pow(es[0, 1], 2))) # visualization cfv.figure() cfv.drawGeometry(g, title='Geometry') cfv.showAndWait() cfv.figure() cfv.drawElementValues(maxFlow, coords, edof, dofsPerNode, elType, None, title='Max flows') cfv.colorBar().SetLabel("Flow") cfv.showAndWait() cfv.figure() cfv.drawNodalValues(a, coords, edof, dofsPerNode, elType, title="Nodal values") cfv.colorBar().SetLabel("Node values") cfv.showAndWait()