Note
Go to the end to download the full example code.
Poisson Equation#
The Poisson equation with fixed boundaries on the bottom, top, left and right end-edges and a unit load, as given in Eq. (1) and Eq. (2), is solved on a rectangle.
(1)#\[\text{div}(\boldsymbol{\nabla} u) + f = 0 \quad \text{in} \quad \Omega\]
(2)#\[ \begin{align}\begin{aligned}u &= 0 \quad \text{on} \quad \Gamma_u\\f &= 1 \quad \text{in} \quad \Omega\end{aligned}\end{align} \]
The Poisson equation is transformed into integral form representation by the divergence (Gauss’s) theorem, see Eq. (3).
(3)#\[\int_\Omega \boldsymbol{\nabla} (\delta u) \cdot \boldsymbol{\nabla} (\Delta u)
\ d\Omega = \int_\Omega \delta u \cdot f \ d\Omega\]


import felupe as fem
mesh = fem.Rectangle(n=2**5).triangulate()
region = fem.RegionTriangle(mesh)
u = fem.Field(region, dim=1)
field = fem.FieldContainer([u])
boundaries = fem.BoundaryDict(
bottom=fem.Boundary(u, fy=0),
top=fem.Boundary(u, fy=1),
left=fem.Boundary(u, fx=0),
right=fem.Boundary(u, fx=1),
)
boundaries.plot(show_lines=False).show()
solid = fem.SolidBody(umat=fem.Laplace(), field=field)
load = fem.SolidBodyForce(field=field, values=1.0)
step = fem.Step([solid, load], boundaries=boundaries)
job = fem.Job([step]).evaluate()
view = mesh.view(point_data={"Field": u.values})
view.plot("Field").show()
Total running time of the script: (0 minutes 0.890 seconds)