Usage Reference for pyvisfile.xdmf¶

This implementation targets XDMF3 and takes available fields directly from the code in the xdmf library. Additional documentation can be found online, but (at the time of this writing, December 2020) does not appear to be kept up to date.

Xdmf Tags¶

DataItem¶

class pyvisfile.xdmf.DataItemType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Data layout of an item.

Function = 3¶
HyperSlab = 2¶
Uniform = 1¶
class pyvisfile.xdmf.DataItemNumberType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Basic number types for an item.

Char = 1¶
Float = 5¶
Int = 3¶
UChar = 2¶
UInt = 4¶
static from_dtype(dtype: dtype[Any]) DataItemNumberType[source]¶
class pyvisfile.xdmf.DataItemFormat(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Format in which the item is stored.

Binary = 3¶
HDF = 2¶
TIFF = 4¶
XML = 1¶
class pyvisfile.xdmf.DataItemEndian(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Endianness of the data stored in the item.

Big = 50¶
Little = 51¶
Native = 52¶
static from_system() DataItemEndian[source]¶
class pyvisfile.xdmf.DataItem(*, dimensions: tuple[int, ...] | None = None, name: str | None = None, itype: DataItemType | None = DataItemType.Uniform, ntype: DataItemNumberType | None = DataItemNumberType.Float, precision: int | None = 4, reference: str | None = None, function: str | None = None, endian: DataItemEndian | None = DataItemEndian.Native, dformat: DataItemFormat | None = DataItemFormat.XML, parent: Element | None = None, data: str | None = None)[source]¶

A DataItem describes the storage of actual values in an XDMF file. This can be inline ASCII data, the path to a binary file or a reference to another DataItem.

dimensions¶

Analogous to numpy.ndarray.shape.

__init__(*, dimensions: tuple[int, ...] | None = None, name: str | None = None, itype: DataItemType | None = DataItemType.Uniform, ntype: DataItemNumberType | None = DataItemNumberType.Float, precision: int | None = 4, reference: str | None = None, function: str | None = None, endian: DataItemEndian | None = DataItemEndian.Native, dformat: DataItemFormat | None = DataItemFormat.XML, parent: Element | None = None, data: str | None = None) None[source]¶
Parameters:
  • parent – if provided, self is appended to the element.

  • reference – path to another DataItem. Use as_reference() to populate.

  • data – data contained inside the DataItem. This is usually a path to a binary file.

classmethod as_reference(reference_name: str, *, parent: Element | None = None) DataItem[source]¶
Parameters:

reference_name – a name or an absolute reference to another DataItem. The name is just the Name attribute of the item, which is assumed to be in the top Domain. If another DataItem needs to be references, or there are multiple domains, use an absolute reference path, as defined in the XDMF docs.

Domain¶

class pyvisfile.xdmf.Domain(*, name: str | None = None, parent: Element | None = None)[source]¶
__init__(*, name: str | None = None, parent: Element | None = None)[source]¶
Parameters:

parent – if provided, self is appended to the element.

Grid¶

class pyvisfile.xdmf.GridType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

General structure of the connectivity.

Collection = 2¶
SubSet = 4¶
Tree = 3¶
Uniform = 1¶
class pyvisfile.xdmf.CollectionType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Spatial = 1¶
Temporal = 2¶
class pyvisfile.xdmf.Grid(*, name: str | None = None, gtype: GridType = GridType.Uniform, ctype: CollectionType | None = None, parent: Element | None = None)[source]¶
__init__(*, name: str | None = None, gtype: GridType = GridType.Uniform, ctype: CollectionType | None = None, parent: Element | None = None) None[source]¶
Parameters:

parent – if provided, self is appended to the element.

Topology¶

class pyvisfile.xdmf.TopologyType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: IntEnum

Element and mesh layouts.

CoRectMesh2D = 4354¶
CoRectMesh3D = 4354¶
Edge_3 = 34¶
Hexahedron = 9¶
Hexahedron_1000 = 57¶
Hexahedron_125 = 52¶
Hexahedron_1331 = 64¶
Hexahedron_20 = 48¶
Hexahedron_216 = 53¶
Hexahedron_24 = 49¶
Hexahedron_27 = 50¶
Hexahedron_343 = 54¶
Hexahedron_512 = 55¶
Hexahedron_64 = 51¶
Hexahedron_729 = 56¶
Hexahedron_Spectral_1000 = 71¶
Hexahedron_Spectral_125 = 66¶
Hexahedron_Spectral_1331 = 72¶
Hexahedron_Spectral_216 = 67¶
Hexahedron_Spectral_343 = 68¶
Hexahedron_Spectral_512 = 69¶
Hexahedron_Spectral_64 = 65¶
Hexahedron_Spectral_729 = 70¶
Mixed = 112¶
NoTopology = 0¶
Polygon = 3¶
Polyhedron = 16¶
Polyline = 2¶
Polyvertex = 1¶
Pyramid = 7¶
Pyramid_13 = 39¶
Quadrilateral = 5¶
Quadrilateral_8 = 37¶
RectMesh2D = 4353¶
RectMesh3D = 4353¶
SMesh2D = 4368¶
SMesh3D = 4368¶
Tetrahedron = 6¶
Tetrahedron_10 = 38¶
Triangle = 4¶
Triangle_6 = 36¶
Wedge = 8¶
Wedge_15 = 40¶
Wedge_18 = 41¶
class pyvisfile.xdmf.Topology(*, ttype: TopologyType, nodes_per_element: int | None = None, number_of_elements: int | None = None, dimensions: tuple[int, ...] | None = None, parent: Element | None = None)[source]¶
__init__(*, ttype: TopologyType, nodes_per_element: int | None = None, number_of_elements: int | None = None, dimensions: tuple[int, ...] | None = None, parent: Element | None = None) None[source]¶
Parameters:

parent – if provided, self is appended to the element.

Geometry¶

class pyvisfile.xdmf.GeometryType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Data layout of the node coordinates.

ORIGIN_DXDY = 5¶
ORIGIN_DXDYDZ = 6¶
VXVY = 3¶
VXVYVZ = 4¶
XY = 1¶
XYZ = 2¶
class pyvisfile.xdmf.Geometry(*, name: str | None = None, gtype: GeometryType = GeometryType.XYZ, parent: Element | None = None)[source]¶
__init__(*, name: str | None = None, gtype: GeometryType = GeometryType.XYZ, parent: Element | None = None)[source]¶
Parameters:

parent – if provided, self is appended to the element.

Attribute¶

class pyvisfile.xdmf.AttributeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Rank of the attribute stored on the mesh.

GlobalId = 205¶
Matrix = 203¶
Scalar = 200¶
Tensor = 202¶
Tensor6 = 204¶
Vector = 201¶
static from_shape(shape: tuple[int, ...]) AttributeType[source]¶
class pyvisfile.xdmf.AttributeCenter(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶

Bases: Enum

Center of the attribute stored on the mesh.

Cell = 101¶
Edge = 103¶
Face = 102¶
Grid = 100¶
Node = 104¶
Other = 105¶
class pyvisfile.xdmf.Attribute(*, name: str | None = None, atype: AttributeType = AttributeType.Scalar, acenter: AttributeCenter = AttributeCenter.Node, parent: Element | None = None)[source]¶
__init__(*, name: str | None = None, atype: AttributeType = AttributeType.Scalar, acenter: AttributeCenter = AttributeCenter.Node, parent: Element | None = None) None[source]¶
Parameters:

parent – if provided, self is appended to the element.

Time¶

class pyvisfile.xdmf.Time(*, value: str, parent: Element | None = None)[source]¶
__init__(*, value: str, parent: Element | None = None)[source]¶
Parameters:

parent – if provided, self is appended to the element.

Information¶

class pyvisfile.xdmf.Information(*, name: str, value: str, parent: Element | None = None)[source]¶
__init__(*, name: str, value: str, parent: Element | None = None)[source]¶
Parameters:

parent – if provided, self is appended to the element.

XInclude¶

class pyvisfile.xdmf.XInclude(*, href: str | None, xpointer: str | None = None, parent: Element | None = None)[source]¶
__init__(*, href: str | None, xpointer: str | None = None, parent: Element | None = None)[source]¶
Parameters:
  • parent – if provided, self is appended to the element.

  • xpointer – path inside the file represented by href.

Writing¶

class pyvisfile.xdmf.DataArray(components: tuple[DataItem, ...], *, name: str | None = None, acenter: AttributeCenter | None = None, atype: AttributeType | None = None)[source]¶

An array represented as a list of DataItems.

__init__(components: tuple[DataItem, ...], *, name: str | None = None, acenter: AttributeCenter | None = None, atype: AttributeType | None = None)[source]¶
Parameters:
  • components – a description of each component of an array.

  • name – name of the array. This name will be used if the array is added as an attribute, otherwise the names of the components are used.

as_data_item(*, parent: Element | None = None) tuple[DataItem, ...][source]¶

Finalize the DataArray and construct DataItems to be written to a file.

class pyvisfile.xdmf.NumpyDataArray(ary: ndarray[Any, dtype[Any]], *, acenter: AttributeCenter | None = None, name: str | None = None)[source]¶
__init__(ary: ndarray[Any, dtype[Any]], *, acenter: AttributeCenter | None = None, name: str | None = None)[source]¶
Parameters:

ary – if this is an object array, each entry is considered a different component and will consist of a separate DataItem.

class pyvisfile.xdmf.XdmfGrid(root: Grid)[source]¶
__init__(root: Grid)[source]¶
add_attribute(ary: DataArray, *, join: bool = True) Attribute[source]¶
Parameters:
  • ary

  • join – If True and ary has multiple components, they are joined using an XDMF Function.

class pyvisfile.xdmf.XdmfUnstructuredGrid(points: DataArray, connectivity: DataArray, *, topology_type: Topology | TopologyType, name: str | None = None, geometry_type: GeometryType | None = None)[source]¶

Bases: XdmfGrid

__init__(points: DataArray, connectivity: DataArray, *, topology_type: Topology | TopologyType, name: str | None = None, geometry_type: GeometryType | None = None)[source]¶
class pyvisfile.xdmf.XdmfWriter(grids: tuple[XdmfGrid, ...], *, arrays: tuple[DataArray, ...] | None = None, tags: tuple[Element, ...] | None = None)[source]¶
__init__(grids: tuple[XdmfGrid, ...], *, arrays: tuple[DataArray, ...] | None = None, tags: tuple[Element, ...] | None = None)[source]¶
Parameters:
  • grids – a tuple of grids to be added to the top Domain. Currently only a single domain is supported.

  • arrays – additional DataArrays to be added to the top Domain, as opposed to as attribute on the grids.

write(filename: str) None[source]¶

Write the the XDMF file.

write_pretty(filename: str) None[source]¶

Produces a nicer-looking XML file with clean indentation.