salvus.mesh.algorithms.unstructured_mesh.io
salvus.mesh.algorithms.unstructured_mesh.io salvus mesh algorithms unstructured_mesh io I/O routines for Salvus’ unstructured mesh.
Functions
read_abaqus_3d()
read_abaqus_3d()def read_abaqus_3d(filename: str | pathlib.Path) -> UnstructuredMesh: ...Read unstructured mesh from abaqus file (experimental).
filenamestr | pathlib.Path — File to open.
read_exodus()
read_exodus()def read_exodus(
filename: str | pathlib.Path,
attach_element_block_indices: bool = False,
select_element_block_indices: typing.Sequence[int] | None = None,
) -> UnstructuredMesh: ...Read unstructured mesh from exodus file.
Only supports first order quads or hexes.
filenamestr | pathlib.Path — File to open.attach_element_block_indicesbool — If True, attach the element block indices to the mesh.select_element_block_indicestyping.Sequence[int] | None — If given, read only these element blocks. Keep in mind that exodus uses 1-based indexing.
read_h5()
read_h5()def read_h5(
filename: str | pathlib.Path, read_data: bool = True
) -> UnstructuredMesh: ...Read an unstructured mesh from an HDF5 Salvus mesh file.
filenamestr | pathlib.Path — File to open.read_databool — read the elemental and element nodal data
read_h5_single_elemental_field()
read_h5_single_elemental_field()def read_h5_single_elemental_field(
filename: str | pathlib.Path, field_name: str
) -> npt.NDArray: ...Read a single elemental field from an HDF5 mesh file.
filenamestr | pathlib.Path — File to open.field_namestr — Name of the field to read.
write_binary_vtk()
write_binary_vtk()def write_binary_vtk(
mesh: UnstructuredMesh, filename: pathlib.Path | str
) -> None: ...Write a binary VTK file.
Please note that this method currently writes the mesh without any attached material parameters. The advantage of using this output format is that ParaView can visualize high-order shapes (e.g. curved elements) in that format.
meshUnstructuredMesh — The mesh to write.filenamepathlib.Path | str — Filename. Make sure it uses a.vtuextension so ParaView recognizes it.
write_exodus()
write_exodus()def write_exodus(
mesh: UnstructuredMesh,
filename: str | pathlib.Path,
element_block_indices: str = "element_block_index",
compression: tuple[str, int] | None = None,
io_size: int = 0,
overwrite: bool = True,
) -> None: ...Write mesh to an Exodus (.e) file.
Since the Exodus file format heavily relies on the use of element blocks, the mesh is required to have some descriptor of element block indices. These typically correspond to discrete regions of the mesh, which share similar properties.
Meshes of 2D dimensionality are written in the XY plane, along Z = 0.
Note that this file format does not support all entity types that belong to native Salvus HDF5 meshes. The following features are written to file:
- Points and connectivity
- Element blocks
- Elemental scalar fields
- Nodal fields
- Global (float) variables
Notably, the following are not retained:
- Elemental nodal fields (e.g., where different properties are
assigned to different nodes of an element, with allowed
discontinuities)
- Global strings and arraysmeshUnstructuredMesh — Mesh to save.filenamestr | pathlib.Path — Location to save the file to. Must end with.e.element_block_indicesstr — Name of the elemental field that contains element block indices.compressiontuple[str, int] | None — Compression settings. Pass a tuple of (method, option), e.g.("gzip", 2). Slows down writing a lot but the resulting files are potentially much smaller.io_sizeint — Determines how floating point variables are stored in the file. Inputs will be converted if required. Possible options include0for machine precision,4for single precision, and8for double precision.overwritebool — Whether to overwrite existing file.
write_h5()
write_h5()def write_h5(
mesh: UnstructuredMesh,
filename: str | pathlib.Path,
datatype: type[np.number] | None = numpy.float64,
compression: tuple[str, int] | None = None,
mode: str = "model",
write_chunk_size: int = 10000,
overwrite: bool = True,
periodic_axes: str | list[str] | None = None,
periodic_atol: float = 1e-08,
) -> None: ...Write the mesh to an h5 file with xdmf descriptor.
meshUnstructuredMesh — The mesh to write.filenamestr | pathlib.Path — Filename.datatypetype[np.number] | None — Datatype to write. Only applies to the elemental field data, coordinates will always be written in double precision. If not set, a suitable data type will be chosen automatically.compressiontuple[str, int] | None — Turn on compression. Pass a tuple of(method, option), e.g.("gzip", 2). Slows down writing a lot but the resulting files are potentially much smaller.modestr — one of"all","model","skeleton","minimal"or"minimal_fast". Controls the content of the mesh file and whether an xdmf file is added. ‘all’: largest file size, multiple block xdmf file and faster reading from file with UnstructuredMesh.from_h5() ‘model’: all data to view the model, single block xdmf file for easy opening in paraview ‘skeleton’: only the first order connectivity can be viewed ‘minimal’: smallest file size, no xdmf. ‘minimal_fast’: Same as minimal, but slightly larger file size for faster reading from file with UnstructuredMesh.from_h5()write_chunk_sizeint — HDF5 chunk size in bytes.overwritebool — Potentially overwrite an existing file.periodic_axesstr | list[str] | None — Pass a coordinate or list of coordinates that you would like to make periodic. For example:xor[x, y]. This is an experimental feature, and should be considered unstable.periodic_atolfloat — Allow for flexibility on the tolerance for coordinate matching when considering periodic boundary conditions. This is an experimental feature, and should be considered unstable.
write_vtp()
write_vtp()def write_vtp(
mesh: UnstructuredMesh,
filename: pathlib.Path | str,
side_sets: typing.Sequence[str] = ("x0", "x1", "y0", "y1", "z0", "z1"),
) -> None: ...Write the mesh to a vtp file, meant for visualization with the GUI.
In 3D, it only writes the hull.
meshUnstructuredMesh — The mesh to write.filenamepathlib.Path | str — filenameside_setstyping.Sequence[str] — Side sets to write.