File: read_dolfin.py

package info (click to toggle)
python-pyvista 0.46.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176,968 kB
  • sloc: python: 94,346; sh: 216; makefile: 70
file content (40 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
.. _read_dolfin_example:

Read FEniCS/Dolfin Meshes
~~~~~~~~~~~~~~~~~~~~~~~~~

PyVista leverages `meshio`_ to read many mesh formats not natively supported
by VTK including the `FEniCS/Dolfin`_ XML format.
This example uses :func:`pyvista.read`.

.. _meshio: https://github.com/nschloe/meshio
.. _FEniCS/Dolfin: https://fenicsproject.org
"""

from __future__ import annotations

import pyvista as pv
from pyvista import examples

# %%
# Let's download an example FEniCS/Dolfin mesh from our example data
# repository. This will download an XML Dolfin mesh and save it to PyVista's
# data directory.
saved_file = examples.download_file('dolfin_fine.xml')
print(saved_file)

# %%
# As shown, we now have an XML Dolfin mesh save locally. This filename can be
# passed directly to PyVista's :func:`pyvista.read` method to be read into
# a PyVista mesh.
dolfin = pv.read(saved_file)
dolfin


# %%
# Now we can work on and plot that Dolfin mesh.
qual = dolfin.cell_quality()
qual.plot(show_edges=True, cpos='xy')
# %%
# .. tags:: load