Note
Go to the end to download the full example code.
Poisson1#
Poisson equation with unit load.

15 import matplotlib.pyplot as plt
16
17 from EasyFEA import Display, ElemType, Models, Simulations
18 from EasyFEA.FEM import Field, BiLinearForm, LinearForm
19 from EasyFEA.Geoms import Domain
20
21 if __name__ == "__main__":
22 Display.Clear()
23
24 # ----------------------------------------------
25 # Mesh
26 # ----------------------------------------------
27
28 contour = Domain((0, 0), (1, 1), 1 / 2**6)
29
30 mesh = contour.Mesh_2D([], ElemType.TRI3, isOrganised=True)
31
32 nodes = mesh.Nodes_Tags(["L0", "L1", "L2", "L3"])
33
34 # ----------------------------------------------
35 # Formulations
36 # ----------------------------------------------
37
38 field = Field(mesh.groupElem, 1)
39
40 @BiLinearForm
41 def bilinear_form(u: Field, v: Field):
42 return u.grad.dot(v.grad)
43
44 @LinearForm
45 def linear_form(v: Field):
46 return 1.0 * v
47
48 weakForms = Models.WeakForms(field, computeK=bilinear_form, computeF=linear_form)
49
50 # ----------------------------------------------
51 # Simulation
52 # ----------------------------------------------
53
54 simu = Simulations.WeakForms(mesh, weakForms)
55
56 simu.add_dirichlet(nodes, [0], ["u"])
57
58 simu.Solve()
59
60 # ----------------------------------------------
61 # Results
62 # ----------------------------------------------
63
64 Display.Plot_Result(simu, "u")
65
66 plt.show()
Total running time of the script: (0 minutes 0.203 seconds)