dolfinx.io

IO module for input data, post-processing file outout and checkpointing

Functions

extract_gmsh_geometry(gmsh_model[, model_name])

For a given gmsh model, extract the mesh geometry as a numpy (N, 3) array where the i-th row corresponds to the i-th node in the mesh.

extract_gmsh_topology_and_markers(gmsh_model)

Extract all entities tagged with a physical marker in the gmsh model, and collect the data per cell type.

ufl_mesh_from_gmsh(gmsh_cell, gdim)

Create a UFL mesh from a Gmsh cell identifier and the geometric dimension.

Classes

FidesWriter(comm, filename, output)

Interface to Fides file formt.

VTKFile(self, comm, filename, mode)

Interface to VTK files

VTXWriter(comm, filename, output)

Interface to VTK files for ADIOS2

XDMFFile(self, comm, filename, file_mode, ...)

class dolfinx.io.FidesWriter(comm: mpi4py.MPI.Comm, filename: str, output: Union[dolfinx.mesh.Mesh, List[dolfinx.fem.function.Function], dolfinx.fem.function.Function])[source]

Bases: dolfinx.cpp.io.FidesWriter

Interface to Fides file formt.

Fides supports first order Lagrange finite elements for the geometry descriptionand first order Lagrange finite elements for functions. All functions has to be of the same element family and same order.

The files can be displayed by Paraview. The storage backend uses ADIOS2.

Initialize a writer for outputting a mesh, a single Lagrange function or list of Lagrange functions sharing the same element family and degree

Parameters
  • comm – The MPI communicator

  • filename – The output filename

  • output – The data to output. Either a mesh, a single first order Lagrange function or list of first order Lagrange functions.

class dolfinx.io.VTKFile(self: dolfinx.cpp.io.VTKFile, comm: MPICommWrapper, filename: os.PathLike, mode: str) None[source]

Bases: dolfinx.cpp.io.VTKFile

Interface to VTK files

VTK supports arbitrary order Lagrange finite elements for the geometry description. XDMF is the preferred format for geometry order <= 2.

write_function(u: Union[List[dolfinx.fem.function.Function], dolfinx.fem.function.Function], t: float = 0.0) None[source]

Write a single function or a list of functions to file for a given time (default 0.0)

write_mesh(mesh: dolfinx.mesh.Mesh, t: float = 0.0) None[source]

Write mesh to file for a given time (default 0.0)

class dolfinx.io.VTXWriter(comm: mpi4py.MPI.Comm, filename: str, output: Union[dolfinx.mesh.Mesh, List[dolfinx.fem.function.Function], dolfinx.fem.function.Function])[source]

Bases: dolfinx.cpp.io.VTXWriter

Interface to VTK files for ADIOS2

VTX supports arbitrary order Lagrange finite elements for the geometry description and arbitrary order (discontinuous) Lagrange finite elements for Functions.

The files can be displayed by Paraview. The storage backend uses ADIOS2.

Initialize a writer for outputting data in the VTX format.

Parameters
  • comm – The MPI communicator

  • filename – The output filename

  • output – The data to output. Either a mesh, a single (discontinuous) Lagrange Function or list of (discontinuous Lagrange Functions.

Note

All Functions for output must share the same mesh and have the same element type.

class dolfinx.io.XDMFFile(self: dolfinx.cpp.io.XDMFFile, comm: MPICommWrapper, filename: os.PathLike, file_mode: str, encoding: dolfinx.cpp.io.XDMFFile.Encoding = <Encoding.HDF5: 0>) None[source]

Bases: dolfinx.cpp.io.XDMFFile

read_mesh(ghost_mode=<GhostMode.shared_facet: 1>, name='mesh', xpath='/Xdmf/Domain') dolfinx.mesh.Mesh[source]

Read mesh data from file

read_meshtags(self: dolfinx.cpp.io.XDMFFile, mesh: dolfinx.cpp.mesh.Mesh, name: str, xpath: str = '/Xdmf/Domain') dolfinx.cpp.mesh.MeshTags_int32[source]
write_function(*args, **kwargs)[source]

Overloaded function.

  1. write_function(self: dolfinx.cpp.io.XDMFFile, function: dolfinx.cpp.fem.Function_float64, t: float, mesh_xpath: str) -> None

  2. write_function(self: dolfinx.cpp.io.XDMFFile, function: dolfinx.cpp.fem.Function_complex128, t: float, mesh_xpath: str) -> None

write_mesh(mesh: dolfinx.mesh.Mesh) None[source]

Write mesh to file for a given time (default 0.0)

dolfinx.io.cell_perm_gmsh()

perm_gmsh(arg0: dolfinx.cpp.mesh.CellType, arg1: int) -> List[int]

Permutation array to map from Gmsh to DOLFINx node ordering

dolfinx.io.distribute_entity_data(arg0: dolfinx.cpp.mesh.Mesh, arg1: int, arg2: numpy.ndarray[numpy.int64], arg3: numpy.ndarray[numpy.int32]) Tuple[numpy.ndarray[numpy.int32], numpy.ndarray[numpy.int32]]