# Sum uf reaction forces R0Sum = np.zeros(2, 'f') for i in range(0, (numNodesY * 2), 2): R0Sum[0] += R0[i, 0] R0Sum[1] += R0[i + 1, 0] eqTotal = eq * L * H * thickness #Total load for plotting purpose print("Total reaction force in x:{:12.3e} y:{:12.3e})".format( R0Sum[0], R0Sum[1])) # Draw the displacements if bDrawMesh: disp = np.array(np.zeros((numNodes, 2)), 'f') rMax = max(abs(max(r)), abs(min(r))) scale = 0.15 * L / rMax for i in range(np.size(disp, 0)): disp[i, 0] = r[i * 2, 0] * scale disp[i, 1] = r[i * 2 + 1, 0] * scale cfv.drawDisplacements(displacements=disp, coords=coords, edof=eldofs, dofsPerNode=2, elType=elTypeInfo[0], title=elTypeInfo[1]) cfv.showAndWait()
print("\nReaction forces in X, top:{:12.3e} bottom:{:12.3e}".format( R0Top, R0Bot)) RySum = 0 RxSum = 0 for i in range(0, (nNody * 2), 2): RxSum += R0[i, 0] RySum += R0[i + 1, 0] print( "Total reaction force in x:{:12.3e} y:{:12.3e} (Total x{:12.3e} y:{:12.3e})" .format(RxSum, RySum, eqTotal[0], eqTotal[1])) # Draw the displacements if bDrawMesh: disp = np.array(np.zeros((nNods, 2)), 'f') rMax = max(abs(max(r)), abs(min(r))) scale = 0.15 * L / rMax for i in range(np.size(disp, 0)): disp[i, 0] = r[i * 2, 0] * scale disp[i, 1] = r[i * 2 + 1, 0] * scale cfv.drawDisplacements(displacements=disp, coords=coords, edof=eldofs, dofsPerNode=2, elType=3, title="4 node quad elements") cfv.showAndWait()
cfv.figure() cfv.drawElementValues(vonMises, coords, edof, dofsPerNode, elType, a, doDrawMesh=True, doDrawUndisplacedMesh=False, title="Example 06 effective stress") cfv.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.
cfv.figure() cfv.drawGeometry(rect.geometry(), title="Geometry") cfv.figure() cfv.drawMesh(mesh.coords, mesh.edof, rect.dofsPerNode, 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)
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. rightSideNodes = rightSideNodes.union(set(meshGen.nodesOnCurve[curveID])) for i in rightSideNodes:
print("Displacement upper-right, x:{:12.3e} y:{:12.3e}".format(xTR, yTR)) print("Displacement lower-right, x:{:12.3e} y:{:12.3e}".format(xBR, yBR)) R0Top = R0[nNody*2 -2,0] R0Bot = R0[0,0] print("\nReaction forces in X, top:{:12.3e} bottom:{:12.3e}".format(R0Top, R0Bot)) RySum = 0 for i in range(1,(nNody*2),2): RySum += R0[i,0] print("Total reaction force in y:{:12.3e} (Total load {:12.3e})".format(RySum,eqTotal[1])) # Draw the displacements if bDrawMesh: disp = np.array(np.zeros((nNods, 2)), 'f') rMax = max(abs(max(r)), abs(min(r))) scale = 0.15 * L / rMax for i in range(np.size(disp, 0)): disp[i, 0] = r[i * 2, 0] * scale disp[i, 1] = r[i * 2 + 1, 0] * scale cfv.drawDisplacements(displacements=disp, coords=coords, edof=eldofs, dofsPerNode=2, elType=2, title="6 node triangle elements") 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')
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)
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) cfv.showAndWait()