.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/WeakForms/Poisson1.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_WeakForms_Poisson1.py: Poisson1 ======== Poisson equation with unit load. Reference: https://scikit-fem.readthedocs.io/en/latest/listofexamples.html#example-1-poisson-equation-with-unit-load .. GENERATED FROM PYTHON SOURCE LINES 13-64 .. image-sg:: /examples/WeakForms/images/sphx_glr_Poisson1_001.png :alt: $u$ :srcset: /examples/WeakForms/images/sphx_glr_Poisson1_001.png :class: sphx-glr-single-img .. code-block:: Python :lineno-start: 14 from EasyFEA import Display, ElemType, Models, Simulations from EasyFEA.fem import Field, BiLinearForm, LinearForm from EasyFEA.Geoms import Domain if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Mesh # ---------------------------------------------- contour = Domain((0, 0), (1, 1), 1 / 2**6) mesh = contour.Mesh_2D([], ElemType.TRI3, isOrganised=True) nodes = mesh.Nodes_Tags(["L0", "L1", "L2", "L3"]) # ---------------------------------------------- # Formulations # ---------------------------------------------- field = Field(mesh.groupElem, 1) @BiLinearForm def bilinear_form(u: Field, v: Field): return u.grad.dot(v.grad) @LinearForm def linear_form(v: Field): return 1.0 * v weakForms = Models.WeakForms(field, computeK=bilinear_form, computeF=linear_form) # ---------------------------------------------- # Simulation # ---------------------------------------------- simu = Simulations.WeakFormSimu(mesh, weakForms) simu.add_dirichlet(nodes, [0], ["u"]) simu.Solve() # ---------------------------------------------- # Results # ---------------------------------------------- Display.Plot_Result(simu, "u") Display.plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.231 seconds) .. _sphx_glr_download_examples_WeakForms_Poisson1.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Poisson1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Poisson1.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Poisson1.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_