DOLFIN / FEniCS XML#

.xml read + write eager

Summary of the specification#

The legacy DOLFIN mesh format is a small XML tree: a <dolfin> root containing a <mesh> whose celltype attribute names the element (interval, triangle, tetrahedron) and whose dim gives the geometric dimension. Inside, <vertices> and <cells> declare their sizes and hold one <vertex> or one <triangle> element per entity, each with an explicit index and its coordinates or node references. Everything is indexed, 0-based and explicit.

Specification at a glance#

root

<dolfin xmlns:dolfin=”…”>

mesh element

<mesh celltype=”triangle” dim=”2”>

vertices

<vertices size=”n”> with <vertex index x y z>

cells

<cells size=”n”> with <triangle index v0 v1 v2> etc.

homogeneity

one cell type per file

status

superseded by XDMF in modern FEniCS

Reading#

import polyxios as px

mesh = px.read("model.xml")
mesh.vertices          # (n, 3)
mesh.element_types     # element groups found in the file

Writing#

px.write(mesh, "out.xml")

This codec takes no format-specific options.

Quirks worth knowing#

  • The format holds a single cell type per file; writing a mixed mesh raises rather than dropping the elements that do not fit.

  • 2D meshes are padded to z = 0 so the vertex array is always (n, 3).

  • Mesh function and mesh value collection blocks are read as attributes where present.

See also

Supported formats — the full format table.