Poisson1#

Poisson equation with unit load.

Reference: https://scikit-fem.readthedocs.io/en/latest/listofexamples.html#example-1-poisson-equation-with-unit-load

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

Total running time of the script: (0 minutes 0.409 seconds)

Gallery generated by Sphinx-Gallery