Note
Go to the end to download the full example code.
Mesh11#
Meshing of a specimen for a spatially oriented tensile test.


12 from EasyFEA import Display, ElemType, np, PyVista
13 from EasyFEA.Geoms import Point, Line, CircleArc, Contour, Domain
14
15 if __name__ == "__main__":
16 Display.Clear()
17
18 # ----------------------------------------------
19 # Configuration
20 # ----------------------------------------------
21
22 # geom
23 L = 1
24 H = 2
25 e = L * 0.5
26
27 # ----------------------------------------------
28 # Mesh
29 # ----------------------------------------------
30
31 p1 = Point(-L / 2)
32 p2 = Point(L / 2)
33 p3 = p2 + [0, H]
34 p4 = p1 + [0, H]
35
36 p5 = Point(e / 2, H / 2)
37 p6 = Point(-e / 2, H / 2)
38
39 l1 = Line(p1, p2)
40 l2 = CircleArc(p2, p3, P=p5)
41 l3 = Line(p3, p4)
42 l4 = CircleArc(p4, p1, P=p6)
43
44 contour = Contour([l1, l2, l3, l4])
45 contour2 = Domain(p1 - [0, H / 2], p2, isHollow=False)
46 contour3 = contour2.copy()
47 contour3.Translate(dy=H + H / 2)
48
49 surfaces = [contour2, contour3]
50
51 PyVista.Plot_Geoms([contour, *surfaces]).show()
52
53 mesh = contour.Mesh_Extrude(
54 [],
55 [0, 0, e],
56 [3],
57 isOrganised=True,
58 elemType=ElemType.HEXA8,
59 additionalSurfaces=surfaces,
60 )
61
62 # ----------------------------------------------
63 # Update coords
64 # ----------------------------------------------
65
66 oldArea = mesh.area
67 mesh.Rotate(-45, mesh.center)
68 assert np.abs(mesh.area - oldArea) / oldArea <= 1e-12
69 mesh.Rotate(45, mesh.center, (1, 0))
70 assert np.abs(mesh.area - oldArea) / oldArea <= 1e-12
71
72 PyVista.Plot_Mesh(mesh).show()
Total running time of the script: (0 minutes 0.455 seconds)