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).
Parameters
filenamestr | pathlib.Path — File to open.
Returns UnstructuredMesh
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.
Parameters
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.
Returns UnstructuredMesh
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.
Parameters
filenamestr | pathlib.Path — File to open.read_databool — read the elemental and element nodal data
Returns UnstructuredMesh
write_binary_vtk()
write_binary_vtk()def write_binary_vtk(
mesh: UnstructuredMesh, filename: typing.Union[str, pathlib.Path]
) -> 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.
Parameters
meshUnstructuredMesh — The mesh to write.filenametyping.Union[str, pathlib.Path] — Filename. Make sure it uses a.vtuextension so ParaView recognizes it.
Returns None
write_h5()
write_h5()def write_h5(
mesh: UnstructuredMesh,
filename: typing.Union[str, pathlib.Path],
datatype: typing.Type[np.number] = numpy.float64,
compression: typing.Optional[typing.Tuple[str, int]] = None,
mode: str = "model",
write_chunk_size: int = 10000,
overwrite: bool = True,
periodic_bcs: typing.Optional[typing.List[typing.Tuple[str, str]]] = None,
) -> None: ...Write the mesh to an h5 file with xdmf descriptor.
Parameters
meshUnstructuredMesh — The mesh to write.filenametyping.Union[str, pathlib.Path] — Filename.datatypetyping.Type[np.number] — Datatype to write.compressiontyping.Optional[typing.Tuple[str, int]] — 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"or"minimal". 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.write_chunk_sizeint — HDF5 chunk size in bytes.overwritebool — Potentially overwrite an existing file.periodic_bcstyping.Optional[typing.List[typing.Tuple[str, str]]] — Pass a tuple of side sets that you would like to make periodic. For example:[("x0", "x1"), ("z0", "z1)]. This option will only work if the mesh has been derived from theStructuredGrid3D.cube()class.
Returns None
write_vtp()
write_vtp()def write_vtp(
mesh: UnstructuredMesh,
filename: typing.Union[str, pathlib.Path],
side_sets: typing.List[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.
Parameters
meshUnstructuredMesh — The mesh to write.filenametyping.Union[str, pathlib.Path] — filenameside_setstyping.List[str] — Side sets to write.
Returns None