gwexpy.interop.meshio_
Interoperate with meshio unstructured-mesh field data.
Interoperability with meshio for unstructured-mesh field data.
meshio reads 40+ mesh formats (XDMF, VTK/VTU, Gmsh, Abaqus, COMSOL, …) into
a uniform meshio.Mesh object with points, cells, point_data
and cell_data.
Since GWexpy’s ScalarField requires a regular grid, this module
interpolates unstructured mesh data to a regular grid using
scipy.interpolate.griddata.
References
https://github.com/nschloe/meshio
Functions
|
Read a VTK/VTU file via meshio and convert to ScalarField. |
|
Read a dolfinx XDMF file via meshio and convert to ScalarField. |
|
Convert a |
- gwexpy.interop.meshio_.from_meshio(cls: type, mesh: Any, *, field_name: str | None = None, grid_resolution: float, method: str = 'linear', axis0: ndarray | None = None, axis0_domain: Literal['time', 'frequency'] = 'time', unit: Any | None = None) ScalarField | VectorField[source]
Convert a
meshio.Meshto a GWexpyScalarFieldorVectorField.The unstructured mesh data is interpolated onto a regular grid using
scipy.interpolate.griddata.- Parameters:
cls (type) –
ScalarFieldorVectorField.mesh (meshio.Mesh) – Input mesh object.
field_name (str, optional) – Key in
point_dataorcell_datato use. Defaults to the first available field.grid_resolution (float) – Spacing of the output regular grid (mandatory).
method ({"linear", "nearest"}, default "linear") – Interpolation method.
axis0 (ndarray, optional) – Values for axis0 (e.g. time steps). Default: singleton
[0].axis0_domain ({"time", "frequency"}, default "time") – Physical domain of axis0.
unit (str or astropy unit, optional) – Unit of the field values.
- Return type:
ScalarField or VectorField
Notes
Only
point_datais supported for interpolation. If the mesh contains onlycell_dataand nopoint_data, aValueErroris raised. To use cell data, first convert it to point data (e.g. meshio’scell_data_to_point_datautility).
- gwexpy.interop.meshio_.from_fenics_xdmf(cls: type, filepath: str | Path, *, field_name: str | None = None, grid_resolution: float, method: str = 'linear', unit: Any | None = None) ScalarField | VectorField[source]
Read a dolfinx XDMF file via meshio and convert to ScalarField.
- Parameters:
cls (type) –
ScalarFieldorVectorField.filepath (str or Path) – Path to the
.xdmffile.field_name (str, optional) – Field name in the XDMF data.
grid_resolution (float) – Regular grid spacing (mandatory).
method ({"linear", "nearest"}, default "linear") – Interpolation method.
unit (str or astropy unit, optional) – Physical unit of the field values.
- Return type:
ScalarField or VectorField
- gwexpy.interop.meshio_.from_fenics_vtk(cls: type, filepath: str | Path, *, field_name: str | None = None, grid_resolution: float, method: str = 'linear', unit: Any | None = None) ScalarField | VectorField[source]
Read a VTK/VTU file via meshio and convert to ScalarField.
- Parameters:
cls (type) –
ScalarFieldorVectorField.filepath (str or Path) – Path to a
.vtkor.vtufile.field_name (str, optional) – Field name in the VTK point/cell data.
grid_resolution (float) – Regular grid spacing (mandatory).
method ({"linear", "nearest"}, default "linear") – Interpolation method.
unit (str or astropy unit, optional) – Physical unit of the field values.
- Return type:
ScalarField or VectorField