Note
Go to the end to download the full example code.
Mesh5_3D#
Mesh of a 3D cracked part.



12 from EasyFEA import Display, ElemType, Models, Simulations, PyVista
13 from EasyFEA.Geoms import Point, Line, Points, Domain, Contour
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 L = 1
19 openCrack = True
20
21 contour = Domain(Point(), Point(L, L))
22
23 # ----------------------------------------------
24 # CRACK
25 # ----------------------------------------------
26
27 line1 = Line(Point(L / 4, L / 2), Point(3 * L / 4, L / 2), isOpen=openCrack)
28 line2 = Line(line1.pt2, line1.pt2 + [0, 0.25, L])
29 line3 = Line(line2.pt2, line1.pt1 + [0, 0.25, L], isOpen=openCrack)
30 line4 = Line(line3.pt2, line1.pt1)
31 crack1 = Points(
32 [
33 Point(L / 2, L / 5, L),
34 Point(2 * L / 3, L / 5, L),
35 Point(L, L / 2, L, isOpen=True),
36 ],
37 isOpen=True,
38 )
39
40 cracks = [Contour([line1, line2, line3, line4], isOpen=openCrack), crack1]
41
42 PyVista.Plot_Geoms([contour, *cracks]).show()
43
44 # WARNING:
45 # only works with TETRA4 and TETRA10
46 # only works with nLayers = []
47 mesh = contour.Mesh_Extrude([], [0, 0, L], [], ElemType.TETRA4, cracks)
48
49 PyVista.Plot_Tags(mesh).show()
50
51 # ----------------------------------------------
52 # SIMU
53 # ----------------------------------------------
54
55 material = Models.ElasIsot(3)
56 simu = Simulations.ElasticSimu(mesh, material)
57
58 simu.add_dirichlet(
59 mesh.Nodes_Conditions(lambda x, y, z: y == 0), [0] * 3, simu.Get_unknowns()
60 )
61 simu.add_dirichlet(mesh.Nodes_Conditions(lambda x, y, z: y == L), [L * 0.05], ["y"])
62 simu.Solve()
63 PyVista.Plot(simu, "uy", 1, plotMesh=True).show()
64
65 Display.plt.show()
Total running time of the script: (0 minutes 2.244 seconds)