fieldconverter.py

This module provides functions for manipulating simulation data objects to be compatible with the underlying machinery of pyvale.

simdata_to_pyvista_interp(sim_data, components, spatial_dims)[source]

Converts the mesh and field data in a SimData object into a pyvista UnstructuredGrid for interpolating the data.

Parameters:
  • sim_data (mh.SimData) – Object containing a mesh and associated field data from a simulation.

  • components (tuple[str,...] | None) – String keys for the components of the field to extract from the simulation data.

  • elem_dim (EDim) – Number of spatial dimensions in the simulation (TWOD or THREED). For mesh-based data this is used to determine the element type and distinguish between 4 node quads in 2D and 4 node tets in 3D. For point cloud data this determines if 2D or 3D Delaunay triangulation is used.

Returns:

pv.UnstructuredGrid – As pyvista grid with attached field data to allow for interpolation on the mesh using the element shape functions.

simdata_to_pyvista_vis(sim_data, spatial_dims)[source]

Converts the mesh and field data in a SimData object into a pyvista UnstructuredGrid or PolyData object for visualisation.

Parameters:
  • sim_data (mh.SimData) – Object containing a mesh and associated field data from a simulation.

  • elem_dim (EDim) – Number of spatial dimensions in the simulation (TWOD or THREED). For mesh-based data this is used to determine the element type and distinguish between 4 node quads in 2D and 4 node tets in 3D. For point cloud data this determines if 2D or 3D Delaunay triangulation is used.

Returns:

pv.UnstructuredGrid | pv.PolyData – A pyvista unstructured grid or poly data object that has no field data attached for visualisation purposes.

extract_surf_mesh(sim_data)[source]

Extracts a surface mesh from a 3D simulation dataclass. Useful for limiting the memory required for analysing sensors that only measure surface fields. This function currently supports:

  • A single connectivity table

  • Higher order retrahedral and hexahedral elements (but not wedges or pyramids)

NOTE: this function returns the surface mesh with element nodal winding consistent with th exodus output format.

Parameters:

sim_data (mh.SimData) – Simulation dataclass containing the 3D mesh from which the surface mesh is to be extracted.

Returns:

mh.SimData – Simulation data class containing the data for the surface mesh.