{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Read FEniCS/Dolfin Meshes\n\nPyVista leverages [meshio](https://github.com/nschloe/meshio) to read\nmany mesh formats not natively supported by VTK including the\n[FEniCS/Dolfin](https://fenicsproject.org) XML format. This example uses\n`pyvista.read`{.interpreted-text role=\"func\"}.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pyvista as pv\nfrom pyvista import examples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let\\'s download an example FEniCS/Dolfin mesh from our example data\nrepository. This will download an XML Dolfin mesh and save it to\nPyVista\\'s data directory.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "saved_file = examples.download_file(\"dolfin_fine.xml\")\nprint(saved_file)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As shown, we now have an XML Dolfin mesh save locally. This filename can\nbe passed directly to PyVista\\'s `pyvista.read`{.interpreted-text\nrole=\"func\"} method to be read into a PyVista mesh.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "dolfin = pv.read(saved_file)\ndolfin" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we can work on and plot that Dolfin mesh.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "qual = dolfin.compute_cell_quality()\nqual.plot(show_edges=True, cpos=\"xy\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }