.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_ch7\ch7_invLaplace.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_auto_ch7_ch7_invLaplace.py: ==================================== 7.01 Inverse Laplace Operator ==================================== We reproduce here the figure 7.1 and 7.2 of the book. Utilitary functions can be found next to this file. Here, we only define codpy-related functions. .. GENERATED FROM PYTHON SOURCE LINES 10-12 Necessary Imports ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 12-28 .. code-block:: Python import os import sys import matplotlib.pyplot as plt from codpy import core try: CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) except NameError: CURRENT_DIR = os.getcwd() data_path = os.path.join(CURRENT_DIR, "data") PARENT_DIR = os.path.abspath(os.path.join(CURRENT_DIR, "..")) sys.path.insert(0, PARENT_DIR) from utils.ch7.ch7_utils import PDE1, PDE2 .. GENERATED FROM PYTHON SOURCE LINES 29-37 Problem statement ------------------------ We solve the following Poisson equation with Dirichlet boundary conditions: $$\Delta u = f, \quad \text{ supp } u \subset \Omega, \quad u_{\partial \Omega}=0$$ where $f$ is sufficient regular and $\Omega$ is a sufficient regular domain. To do so we select a mesh, and a kernel, which approximates this equation by approximating the solution as a function $u \in \mathcal{H}_k$ This leads to the equation $(\Delta_k u)(X) = f(X)$, $\Delta_k$ being the approximation of the Laplace-Beltrami operator defined in the book. A solution to this equation is computed as $u = (\Delta_k)^{-1} f$. .. GENERATED FROM PYTHON SOURCE LINES 39-42 Regular mesh ------------------------ This figure displays a regular mesh for the domain $\Omega = [0,1]^2$, where $f$ is plotted in the left-hand side, and the solution $u$ in the right-hand side. .. GENERATED FROM PYTHON SOURCE LINES 42-46 .. code-block:: Python PDE1() plt.show() .. image-sg:: /auto_ch7/images/sphx_glr_ch7_invLaplace_001.png :alt: f(x), solution :srcset: /auto_ch7/images/sphx_glr_ch7_invLaplace_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-50 Irregular mesh ------------------------ This figure computes a Poisson equation on an unstructured mesh generated by a bimodal Gaussian random variable, with $f$ plotted on the left and the solution $u$ on the right. .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python PDE2() plt.show() .. image-sg:: /auto_ch7/images/sphx_glr_ch7_invLaplace_002.png :alt: f(x), solution :srcset: /auto_ch7/images/sphx_glr_ch7_invLaplace_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.759 seconds) .. _sphx_glr_download_auto_ch7_ch7_invLaplace.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch7_invLaplace.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ch7_invLaplace.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ch7_invLaplace.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_