.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/unstructured/plot_tricontourf_unstructured.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_examples_unstructured_plot_tricontourf_unstructured.py: Contour from an unstructured mesh (no interpolation) ==================================================== This example reads and plots a contour of an OpenFoam vector field from an unstructured mesh by triangulation WITHOUT interpolation on a structured grid .. GENERATED FROM PYTHON SOURCE LINES 10-15 Reads the mesh -------------- .. note:: It reads the mesh coordinates and stores them in variables x, y and z .. GENERATED FROM PYTHON SOURCE LINES 15-23 .. code-block:: Python # import readmesh function from fluidfoam package from fluidfoam import readmesh sol = '../../output_samples/pipeline/' x, y, z = readmesh(sol) .. rst-class:: sphx-glr-script-out .. code-block:: none Reading file ../../output_samples/pipeline//constant/polyMesh/owner Reading file ../../output_samples/pipeline//constant/polyMesh/faces Reading file ../../output_samples/pipeline//constant/polyMesh/points Reading file ../../output_samples/pipeline//constant/polyMesh/neighbour .. GENERATED FROM PYTHON SOURCE LINES 24-29 Reads vector and scalar field ----------------------------- .. note:: It reads volume scalar field from an unstructured mesh and stores it .. GENERATED FROM PYTHON SOURCE LINES 29-38 .. code-block:: Python # import readvector and readscalar functions from fluidfoam package from fluidfoam import readvector, readscalar timename = '25' vel = readvector(sol, timename, 'Ub') alpha = readscalar(sol, timename, 'alpha') .. rst-class:: sphx-glr-script-out .. code-block:: none Reading file ../../output_samples/pipeline/25/Ub Reading file ../../output_samples/pipeline/25/alpha .. GENERATED FROM PYTHON SOURCE LINES 39-44 Plots the contour of the volscalarfield alpha and a patch ----------------------------------------------------------------------------- .. note:: The scalar field alpha reprensents the concentration of sediment in in a 2D two-phase flow simulation of erosion below a pipeline .. GENERATED FROM PYTHON SOURCE LINES 44-65 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt # Define plot parameters fig, ax = plt.subplots(figsize=(8.5, 3), dpi=100) plt.rcParams.update({'font.size': 10}) plt.xlabel('x/D') plt.ylabel('y/D') d = 0.05 # Add a cuircular patch representing the pipeline circle = plt.Circle((0, 0), radius=0.5, fc='silver', zorder=10, edgecolor='k') plt.gca().add_patch(circle) # Plots the contour of sediment concentration levels = np.arange(0.0, 0.63, 0.001) plt.tricontourf(x/d, y/d, alpha, cmap=plt.cm.Reds, levels=levels) ax.set(xlim=(-2, 7), ylim=(-1.5, 1.5)) plt.show() .. image-sg:: /auto_examples/unstructured/images/sphx_glr_plot_tricontourf_unstructured_001.png :alt: plot tricontourf unstructured :srcset: /auto_examples/unstructured/images/sphx_glr_plot_tricontourf_unstructured_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 10.542 seconds) .. _sphx_glr_download_auto_examples_unstructured_plot_tricontourf_unstructured.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_tricontourf_unstructured.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_tricontourf_unstructured.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_tricontourf_unstructured.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_