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


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