def drawMesh(self, figMesh): """Draw mesh in provided figure""" cfv.figure(figMesh.nr) cfv.clf() cfv.draw_mesh(self.mesh.coords, self.mesh.edof, self.rect.dofsPerNode, self.rect.elementType, filled=True, title="Mesh") #Draws the mesh.
def drawMesh(self): cfv.figure(self.fig2.nr) cfv.clf() cfv.draw_mesh(coords=self.coords, edof=self.edof, dofs_per_node=self.meshGen.dofsPerNode, el_type=self.meshGen.elType, filled=True, title="Example 01") cfv.addText("This is a Text", pos=(1, -0.3), angle=45) #Adds a text in world space ourLabel = cfv.label("This is a Label", pos=(100, 200), angle=-45) #Adds a label in the screen space ourLabel.text = "Label, changed." #We can change the attributes of labels and texts, such as color, text, and position. ourLabel.textColor = 'r' #Make it red. (1,0,0) would also have worked. ourLabel.position = (20, 30)
solver.addBC(rect.leftId, 0.0) solver.addForceTotal(rect.topId, -10e5, dimension=2) results = solver.execute() # ---- Visualise results ---------------------------------------------------- cfu.info("Drawing results...") cfv.figure() cfv.draw_geometry(rect.geometry(), title="Geometry") cfv.figure() cfv.draw_mesh(mesh.coords, mesh.edof, rect.dofsPerNode, rect.elementType, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.draw_displacements(results.a, mesh.coords, mesh.edof, rect.dofsPerNode, rect.elementType, doDrawUndisplacedMesh=False, title="Displacements", magnfac=1) cfv.figure() cfv.draw_elementValues(results.elForces,
solver = cfslv.Plan2DSolver(mesh) solver.addBC(rect.left_id, 0.0) solver.addForceTotal(rect.top_id, -10e5, dimension=2) results = solver.execute() # ---- Visualise results ---------------------------------------------------- cfu.info("Drawing results...") cfv.figure() cfv.draw_geometry(rect.geometry(), title="Geometry") cfv.figure() cfv.draw_mesh(mesh.coords, mesh.edof, rect.dofs_per_node, rect.element_type, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.draw_displacements(results.a, mesh.coords, mesh.edof, rect.dofs_per_node, rect.element_type, draw_undisplaced_mesh=False, title="Displacements", magnfac=1) cfv.figure() cfv.draw_element_values(results.el_forces, mesh.coords, mesh.edof, rect.dofs_per_node, rect.element_type, results.a, draw_elements=True, draw_undisplaced_mesh=False, title="Effective Stress", magnfac=1) #cfv.colorBar().SetLabel("Effective stress") cfu.info("Done drawing...")
# Hold Left Mouse button to rotate. # Hold right mouse button to zoom. # Hold SHIFT and left mouse button to pan. # Hold SHIFT and right mouse button to change the field of view. # Hold Ctrl and left mouse button to roll the camera. # Draw geometry cfv.draw_geometry(g, draw_points=False) # Draw mesh cfv.figure() cfv.draw_mesh(coords=coords, edof=edof, dofs_per_node=dofs_per_node, el_type=el_type, filled=True) # Add a text in world space cfv.add_text("This is a Text", pos=(1, 0.5, 0.5), angle=45) # Add a label in the screen space our_label = cfv.add_label("This is a Label", pos=(20, 30), angle=-45) # We can change the attributes of labels and texts, such as color and position. our_label.text = "Label, changed."
coords, edof, dofs, bdofs, elementmarkers = mesh.create() # ---- Visualise mesh ------------------------------------------------------- # Hold left mouse button to pan. # Hold right mouse button to zoom. # Draw the geometry. cfv.draw_geometry(g, label_curves=True) # New figure window cfv.figure() # Draws the mesh. cfv.draw_mesh(coords=coords, edof=edof, dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type, filled=True, title="Example 02") # Show grid cfv.show_grid() # Enter main loop cfv.show_and_wait()
# Element type 3 is quad. (2 is triangle. See user manual for more element types) mesh.el_type = 3 # Degrees of freedom per node. mesh.dofs_per_node = 1 # mesh.gmsh_exec_path = "D:\\vsmn20-software\\gmsh\gmsh.exe" coords, edof, dofs, bdofs, elementmarkers = mesh.create() # ---- Visualise mesh ------------------------------------------------------- # Draw geometry cfv.draw_geometry(g) # Draw mesh cfv.figure() cfv.draw_mesh(coords, edof, dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type, filled=True) # Enter main loop cfv.show_and_wait()
# Create mesh coords, edof, dofs, bdofs, elementmarkers = cfm.mesh(g, el_type, 0.3, dofs_per_node) #coords, edof, dofs, bdofs, _ = cfm.mesh( # g, el_type, 0.3, dofs_per_node, gmsh_exec_path="D:\\vsmn20-software\\gmsh\gmsh.exe") # ---- Visualise mesh ------------------------------------------------------- # Create two axes that are viewed from the same camera: cfv.figure() a1 = cfv.subplot(121) a2 = cfv.subplot(122) cam = cfv.camera3d() a1.camera = a2.camera = cam # Draw geometry and mesh cfv.draw_geometry(g, axes=a1) cfv.draw_mesh(coords=coords, edof=edof, dofsPerNode=dofs_per_node, elType=el_type, filled=False, axes=a2) # Enter main loop cfv.show_and_wait()
von_mises.append( np.math.sqrt( pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * pow(es[2], 2))) # ---- Visualise results ---------------------------------------------------- cfu.info("Drawing results...") cfv.figure() cfv.draw_geometry(g, title="Geometry") cfv.figure() cfv.draw_mesh(coords=coords, edof=edof, dofs_per_node=dofs_per_node, el_type=el_type, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.draw_displacements(a, coords, edof, dofs_per_node, el_type, draw_undisplaced_mesh=False, title="Displacements", magnfac=25.0) cfv.figure() cfv.draw_element_values(von_mises,