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



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