.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/ex10_poisson-equation.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_ex10_poisson-equation.py: Poisson Equation ---------------- The `Poisson equation `_ .. math:: \text{div}(\boldsymbol{\nabla} v) + f = 0 \quad \text{in} \quad \Omega with fixed boundaries on the bottom, top, left and right end-edges .. math:: v = 0 \quad \text{on} \quad \Gamma_v and a unit load .. math:: f = 1 \quad \text{in} \quad \Omega is solved on a unit rectangle with triangles. .. GENERATED FROM PYTHON SOURCE LINES 27-37 The Poisson equation is transformed into integral form representation by the `divergence (Gauss's) theorem `_. .. math:: \int_\Omega \boldsymbol{\nabla} v \cdot \boldsymbol{\nabla} u \ d\Omega = \int_\Omega f \cdot v \ d\Omega For the :func:`~felupe.newtonrhapson` to converge, the *linear form* of the Poisson equation is also required. .. GENERATED FROM PYTHON SOURCE LINES 37-71 .. code-block:: Python import felupe as fem from felupe.math import ddot, grad mesh = fem.Rectangle(n=2**5).triangulate() region = fem.RegionTriangle(mesh) scalar = fem.Field(region) field = fem.FieldContainer([scalar]) @fem.Form(v=field, u=field) def a(): "Container for a bilinear form." return [lambda v, u, **kwargs: ddot(grad(v), grad(u))] @fem.Form(v=field) def L(): "Container for a linear form." return [lambda v, **kwargs: ddot(grad(v), grad(scalar)) - kwargs["scale"] * v] poisson = fem.FormItem(bilinearform=a, linearform=L, kwargs={"scale": 1.0}) boundaries = { "bottom-or-left": fem.Boundary(field[0], fx=0, fy=0, mode="or"), "top-or-right": fem.Boundary(field[0], fx=1, fy=1, mode="or"), } step = fem.Step([poisson], boundaries=boundaries) job = fem.Job([step]).evaluate() view = mesh.view(point_data={"Field": scalar.values}) view.plot("Field", show_undeformed=False).show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/images/sphx_glr_ex10_poisson-equation_001.png :alt: ex10 poisson equation :srcset: /examples/images/sphx_glr_ex10_poisson-equation_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/felupe/checkouts/latest/docs/examples/images/sphx_glr_ex10_poisson-equation_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.515 seconds) .. _sphx_glr_download_examples_ex10_poisson-equation.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex10_poisson-equation.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex10_poisson-equation.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_