Пример #1
0
# ---- 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()
Пример #2
0
# ---- 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

#cfv.show_grid()

# Enter main loop

cfv.show_and_wait()
Пример #3
0
# ---- 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.

#our_label.text = "Label, changed." 

# Make it red. (1,0,0) would also have worked.
Пример #4
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))

# Enter main loop

cfv.show_and_wait()

print("Done.")
Пример #5
0
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)
cfv.colorbar()

cfv.showAndWait()
Пример #6
0
# ---- 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,
                        mesh.el_type,
                        None,
                        draw_elements=False,
                        draw_undisplaced_mesh=False,
                        title="Example 6c - Effective stress")

cfv.figure()
Пример #7
0
    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,
                        draw_undisplaced_mesh=False,
                        title="Example 6 - Effective stress")

cfv.figure()
cfv.draw_displacements(a,
Пример #8
0
        es, et = cfc.planqs(ex[i,:], ey[i,:], 
                        elprop[elementmarkers[i]][0], 
                        elprop[elementmarkers[i]][1], 
                        ed[i,:])
        
        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, coords, edof, dofs_per_node, el_type, a, 
                      draw_elements=True, draw_undisplaced_mesh=False, 
                      title="Effective Stress", magnfac=25.0)

cfv.colorbar()

# cfu.info("Done drawing...")