common.io
Classes
Dataclass protocol. See https://stackoverflow.com/a/55240861 |
Functions
|
Load options dictionary from YAML file. |
|
Dump options dictionary from YAML file. |
|
Read mesh from dolfinx XDMF or Gmsh MSH file. |
|
Read dolfinx mesh, subdomain and boundary identifiers from GMSH file. |
|
Read dolfinx mesh, subdomain and boundary identifiers from XDMF file. |
|
Read Gmsh mesh (MSH format) and write to disk in DOLFINX XDMF format. |
|
Copy input file to results directory. |
|
Write version and git hash to results directory. |
|
Write host info and dolfinx, PETSc versions to file. |
|
Factory to convert dataclasses to dict, to allow serializing Enums for yaml.dump(). |
Module Contents
- class common.io.IsDataclass[source]
Bases:
ProtocolDataclass protocol. See https://stackoverflow.com/a/55240861
- common.io.load_options(input_file: os.PathLike[str] | str) dict[str, Any][source]
Load options dictionary from YAML file.
- Parameters:
input_file – path to options input file
- Returns:
options dictionary
- common.io.dump_options(options: IsDataclass, file: os.PathLike[str] | str) None[source]
Dump options dictionary from YAML file.
- Parameters:
options – options dataclass to be written to file
file – output file
- common.io.read_mesh(mesh_file: os.PathLike[str] | str) tuple[dolfinx.mesh.Mesh, dolfinx.mesh.MeshTags | None, dolfinx.mesh.MeshTags | None][source]
Read mesh from dolfinx XDMF or Gmsh MSH file.
Both formats are supported in parallel.
- Parameters:
mesh_file – path to mesh file
- Returns:
mesh
boundary identifiers or None
- common.io._read_mesh_gmsh(mesh_file: os.PathLike[str] | str) tuple[dolfinx.mesh.Mesh, dolfinx.mesh.MeshTags | None, dolfinx.mesh.MeshTags | None][source]
Read dolfinx mesh, subdomain and boundary identifiers from GMSH file.
- Parameters:
mesh_file – input Gmsh mesh file
- Returns:
mesh
boundary identifiers or None
subdomain identifiers
- common.io._read_mesh_xdmf(mesh_file: os.PathLike[str] | str) tuple[dolfinx.mesh.Mesh, dolfinx.mesh.MeshTags | None, dolfinx.mesh.MeshTags | None][source]
Read dolfinx mesh, subdomain and boundary identifiers from XDMF file.
The boundary identifiers – ‘facet tags’ – have to be labeled “Facet tags” (dolfinx default) or “mesh_tags”. The subdomain identifiers must be labeled “Cell tags”.
- Parameters:
path – input XDMF mesh file
- Returns:
mesh
subdomain identifiers
boundary identifiers or None
- common.io.convert_msh_to_xdmf(msh_file: os.PathLike[str] | str) None[source]
Read Gmsh mesh (MSH format) and write to disk in DOLFINX XDMF format.
- Parameters:
path – input Gmsh mesh file
- common.io.copy_inputfile(inputfile: os.PathLike[str] | str, write_path: os.PathLike[str] | str) None[source]
Copy input file to results directory.
- Parameters:
inputfile – options YAML input file
write_path – path where simulation output files are stored
- common.io.write_version_githash(repo_file: os.PathLike[str] | str, version: str, write_path: os.PathLike[str] | str) None[source]
Write version and git hash to results directory.
Deprecated since version 0.4.0: replaced by
common.utils.capture_environment()- Parameters:
repo_file – path to file within git repository (__file__ of calling class)
version – package version to write
write_path – path where simulation output files are stored
- common.io.write_sysinfo(write_path: os.PathLike[str] | str) None[source]
Write host info and dolfinx, PETSc versions to file.
Deprecated since version 0.4.0: replaced by
common.utils.capture_environment()- Parameters:
write_path – path where simulation output files are stored