coords, edof, dofs, bdofs, _ = cfm.mesh(g, el_type, dofs_per_node) #coords, edof, dofs, bdofs, _ = cfm.mesh( # g, el_type, dofs_per_node, gmsh_exec_path="D:\\vsmn20-software\\gmsh\gmsh.exe") # ---- Visualise mesh ------------------------------------------------------- # 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.
# ---- Create mesh ---------------------------------------------------------- mesh = cfm.GmshMesh(g) # 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.el_size_factor = 0.01 # 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()
print("Computing element forces...") ed = cfc.extractEldisp(edof,a) for i in range(np.shape(ex)[0]): es, et, eci = cfc.flw2i8s(ex[i,:], ey[i,:], ep, Ddict[elementmarkers[i]], ed[i,:]) # Do something with es, et, eci here. # ---- Visualise results ---------------------------------------------------- print("Visualising...") cfv.set_figure_dpi(100) cfv.draw_geometry(g, title="Geometry") # 8-node quads are drawn as simple quads. cfv.figure() cfv.draw_mesh(coords, edof, dofs_per_node, el_type, filled=False) cfv.figure() cfv.draw_nodal_values_shaded(a, coords, edof, title="Temperature", dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type, draw_elements=True) cbar = cfv.colorbar(orientation="horizontal") cbar.set_label("Temperature") cfv.text("The bend has high conductivity", (125,125)) cfv.text("This part has low conductivity", (160,-50))
# Degrees of freedom per node. mesh.dofs_per_node = 2 mesh.el_size_factor = 0.05 # mesh.gmsh_exec_path = "D:\\vsmn20-software\\gmsh\gmsh.exe" 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, labelCurves=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
# ---- Solve problem -------------------------------------------------------- solver = cfslv.Flow2DSolver(mesh) solver.addBC(rect.left_id, 0.0) solver.addBC(rect.right_id, 120.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.dofs_per_node, rect.element_type, filled=True, title="Mesh") #Draws the mesh. cfv.figure() cfv.draw_nodal_values_shaded(results.a, mesh.coords, mesh.edof) cfv.colorbar() cfv.figure() cfv.draw_nodal_values_contourf(results.a, mesh.coords, mesh.edof)
# Calc and append effective stress to list. vonMises.append( sqrt(pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * es[2])) # es: [sigx sigy tauxy] # ---- Visualise results ---------------------------------------------------- cfu.info("Visualising...") cfv.figure() cfv.draw_geometry(g, draw_points=True, label_curves=True, label_points=True, title="Example 6a - Geometry") cfv.figure() cfv.draw_mesh(coords, edof, dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type, title="Example 6b - Meshing") cfv.figure() cfv.draw_element_values(vonMises, coords, edof, mesh.dofs_per_node,
es, et = cfc.planqs(ex[i, :], ey[i, :], ep, D, ed[i, :]) # Calc and append effective stress to list. vonMises.append( sqrt(pow(es[0], 2) - es[0] * es[1] + pow(es[1], 2) + 3 * es[2])) ## es: [sigx sigy tauxy] # ---- Visualise results ---------------------------------------------------- cfu.info("Visualising...") cfv.figure() cfv.draw_geometry(g, draw_points=True, label_curves=True, label_points=True) cfv.figure() cfv.draw_mesh(coords, edof, dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type) cfv.figure() cfv.draw_element_values(vonMises, coords, edof, mesh.dofs_per_node, mesh.el_type, None, draw_elements=False,
# create lines between points g.spline([0, 1]) g.spline([1, 2]) g.spline([2, 3], marker=80) # marker just to name g.spline([3, 4]) g.spline([4, 5]) g.spline([5, 6]) g.spline([6, 7], marker=90) g.spline([7, 0]) # make an surface area g.surface([0, 1, 2, 3, 4, 5, 6, 7]) # plot geometry cfv.draw_geometry(g) cfv.showAndWait() # mesh generation elType = 3 # quadrature element dofsPerNode = 1 # 1 dof # generate mesh paramters meshGen = cfm.GmshMeshGenerator(g) meshGen.elSizeFactor = 1.0 # factor that changes element sizes meshGen.elType = elType meshGen.dofsPerNode = dofsPerNode # create mesh coords, edof, dofs, bdofs, elementmarkers = meshGen.create()
# Degrees of freedom per node. mesh.dofs_per_node = 2 mesh.el_size_factor = 0.05 # mesh.gmsh_exec_path = "D:\\vsmn20-software\\gmsh\gmsh.exe" 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, title="Example 2 - Geometry") # 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 2 - Mesh") # Enter main loop