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)¶

Bases: enum.Enum

Data layout of an item.

Function = 3¶
HyperSlab = 2¶
Uniform = 1¶
class pyvisfile.xdmf.DataItemNumberType(value)¶

Bases: enum.Enum

Basic number types for an item.

Char = 1¶
Float = 5¶
Int = 3¶
UChar = 2¶
UInt = 4¶
static from_dtype(dtype)¶
Parameters

dtype (numpy.dtype) –

Return type

pyvisfile.xdmf.DataItemNumberType

class pyvisfile.xdmf.DataItemFormat(value)¶

Bases: enum.Enum

Format in which the item is stored.

Binary = 3¶
HDF = 2¶
TIFF = 4¶
XML = 1¶
class pyvisfile.xdmf.DataItemEndian(value)¶

Bases: enum.Enum

Endianess of the data stored in the item.

Big = 50¶
Little = 51¶
Native = 52¶
static from_system()¶
Return type

pyvisfile.xdmf.DataItemEndian

class pyvisfile.xdmf.DataItem(*, dimensions=None, name=None, itype=<DataItemType.Uniform: 1>, ntype=<DataItemNumberType.Float: 5>, precision=4, reference=None, function=None, endian=<DataItemEndian.Native: 52>, dformat=<DataItemFormat.XML: 1>, parent=None, data=None)¶

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=None, name=None, itype=<DataItemType.Uniform: 1>, ntype=<DataItemNumberType.Float: 5>, precision=4, reference=None, function=None, endian=<DataItemEndian.Native: 52>, dformat=<DataItemFormat.XML: 1>, parent=None, data=None)¶
Parameters
classmethod as_reference(reference_name, *, parent=None)¶
Parameters
  • reference_name (str) – 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.

  • parent (Optional[xml.etree.ElementTree.Element]) –

Return type

pyvisfile.xdmf.DataItem

Domain¶

class pyvisfile.xdmf.Domain(*, name=None, parent=None)¶
__init__(*, name=None, parent=None)¶
Parameters

Grid¶

class pyvisfile.xdmf.GridType(value)¶

Bases: enum.Enum

General structure of the connectivity.

Collection = 2¶
SubSet = 4¶
Tree = 3¶
Uniform = 1¶
class pyvisfile.xdmf.CollectionType(value)¶

Bases: enum.Enum

An enumeration.

Spatial = 1¶
Temporal = 2¶
class pyvisfile.xdmf.Grid(*, name=None, gtype=<GridType.Uniform: 1>, ctype=None, parent=None)¶
__init__(*, name=None, gtype=<GridType.Uniform: 1>, ctype=None, parent=None)¶
Parameters

Topology¶

class pyvisfile.xdmf.TopologyType(value)¶

Bases: enum.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, nodes_per_element=None, number_of_elements=None, dimensions=None, parent=None)¶
__init__(*, ttype, nodes_per_element=None, number_of_elements=None, dimensions=None, parent=None)¶
Parameters

Geometry¶

class pyvisfile.xdmf.GeometryType(value)¶

Bases: enum.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=None, gtype=<GeometryType.XYZ: 2>, parent=None)¶
__init__(*, name=None, gtype=<GeometryType.XYZ: 2>, parent=None)¶
Parameters

Attribute¶

class pyvisfile.xdmf.AttributeType(value)¶

Bases: enum.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)¶
Parameters

shape (Tuple[int, ..]) –

Return type

pyvisfile.xdmf.AttributeType

class pyvisfile.xdmf.AttributeCenter(value)¶

Bases: enum.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=None, atype=<AttributeType.Scalar: 200>, acenter=<AttributeCenter.Node: 104>, parent=None)¶
__init__(*, name=None, atype=<AttributeType.Scalar: 200>, acenter=<AttributeCenter.Node: 104>, parent=None)¶
Parameters

Time¶

class pyvisfile.xdmf.Time(*, value, parent=None)¶
__init__(*, value, parent=None)¶
Parameters

Information¶

class pyvisfile.xdmf.Information(*, name, value, parent=None)¶
__init__(*, name, value, parent=None)¶
Parameters

XInclude¶

class pyvisfile.xdmf.XInclude(*, href, xpointer=None, parent=None)¶
__init__(*, href, xpointer=None, parent=None)¶
Parameters
  • parent (Optional[xml.etree.ElementTree.Element]) – if provided, self is appended to the element.

  • xpointer (Optional[str]) – path inside the file represented by href.

  • href (Optional[str]) –

Writing¶

class pyvisfile.xdmf.DataArray(components, *, name=None, acenter=None, atype=None)¶

An array represented as a list of DataItems.

__init__(components, *, name=None, acenter=None, atype=None)¶
Parameters
as_data_item(*, parent=None)¶

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

Parameters

parent (Optional[xml.etree.ElementTree.Element]) –

Return type

Tuple[pyvisfile.xdmf.DataItem, ..]

class pyvisfile.xdmf.NumpyDataArray(ary, *, acenter=None, name=None)¶
__init__(ary, *, acenter=None, name=None)¶
Parameters
class pyvisfile.xdmf.XdmfGrid(root)¶
__init__(root)¶

Initialize self. See help(type(self)) for accurate signature.

Parameters

root (pyvisfile.xdmf.Grid) –

add_attribute(ary, *, join=True)¶
Parameters
  • ary (pyvisfile.xdmf.DataArray) –

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

Return type

pyvisfile.xdmf.Attribute

class pyvisfile.xdmf.XdmfUnstructuredGrid(points, connectivity, *, topology_type, name=None, geometry_type=None)¶

Bases: pyvisfile.xdmf.XdmfGrid

__init__(points, connectivity, *, topology_type, name=None, geometry_type=None)¶

Initialize self. See help(type(self)) for accurate signature.

Parameters
class pyvisfile.xdmf.XdmfWriter(grids, *, arrays=None, tags=None)¶
__init__(grids, *, arrays=None, tags=None)¶
Parameters
write(filename)¶

Write the the XDMF file.

write_pretty(filename)¶

Produces a nicer-looking XML file with clean indentation.