.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_ch7\ch7_convexHull.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_convexHull.py: ==================================== 7.05 Convex Hull Algorithm ==================================== We reproduce here the figure 7.7 & 7.8 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 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 CHA1D, CHA2D .. GENERATED FROM PYTHON SOURCE LINES 29-36 Problem statement ------------------------ We consider the Convex Hull algorithm and compute $$u(t,\cdot) = y^+(t,\cdot)_\# u_0(\cdot), \quad y(t,x) = x + t f'(u_0(x)),$$ Where $y^+(t,\cdot)$ is computed as $$y^+(t,\cdot) = \nabla h^+(t,\cdot), \quad \nabla h(t,\cdot) = y(t,\cdot),$$ and $h^+(t,\cdot)$ is the convex hull of $h$. .. GENERATED FROM PYTHON SOURCE LINES 38-43 One dimensional ------------------------ This figures illustrates this computation for the one-dimensional Burgers equation : $$\partial_t u + \frac{1}{2}\partial_x u^2 =0,$$ The left-hand figure is the initial condition at time zero, since the solution at middle represent the conservative solution at time 1, and the entropy solution is plot at right. .. GENERATED FROM PYTHON SOURCE LINES 43-47 .. code-block:: Python CHA1D() plt.show() .. image-sg:: /auto_ch7/images/sphx_glr_ch7_convexHull_001.png :alt: initial cond., conservative sol., entropy sol. :srcset: /auto_ch7/images/sphx_glr_ch7_convexHull_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 48-52 Two dimensional ------------------------ This figures illustrates the two dimensional case : $$\partial_t u + \frac{1}{2}\nabla \cdot(u^2,u^2)=0$$ .. GENERATED FROM PYTHON SOURCE LINES 52-55 .. code-block:: Python CHA2D() plt.show() pass .. image-sg:: /auto_ch7/images/sphx_glr_ch7_convexHull_002.png :alt: initial cond., conservative sol., entropy sol. :srcset: /auto_ch7/images/sphx_glr_ch7_convexHull_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.323 seconds) .. _sphx_glr_download_auto_ch7_ch7_convexHull.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ch7_convexHull.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ch7_convexHull.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ch7_convexHull.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_