fieldconverter¶
This module provides functions for manipulating simulation data objects to be compatible with the underlying machinery of pyvale.
- pyvale.fieldconverter.extract_surf_mesh(sim_data: SimData) SimData [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.
- pyvale.fieldconverter.scale_length_units(scale: float, sim_data: SimData, disp_comps: tuple[str, ...] | None = None) SimData [source]¶
Used to scale the length units of a simulation. Commonly used to convert SI units to mm for use with visualisation tools and rendering algorithms.
- Parameters:
scale (float) -- Scale multiplier used to scale the coordinates and displacement fields if specified.
sim_data (mh.SimData) -- Simulation dataclass that will be scaled.
disp_comps (tuple[str,...] | None, optional) -- Tuple of string keys for the displacement keys to be scaled, by default None. If None then the displacements are not scaled.
- Returns:
mh.SimData -- Simulation dataclass with scaled length units.
- pyvale.fieldconverter.simdata_to_pyvista(sim_data: SimData, components: tuple[str, ...] | None, elem_dims: int) tuple[UnstructuredGrid, UnstructuredGrid] [source]¶
Converts the mesh and field data in a SimData object into a pyvista UnstructuredGrid for sampling (interpolating) the data and visualisation.
- 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 (int) -- Number of spatial dimensions (2 or 3) used to determine the element types in the mesh from the number of nodes per element.
- Returns:
tuple[pv.UnstructuredGrid,pv.UnstructuredGrid] -- The first UnstructuredGrid has the field components attached as dataset arrays. The second has no field data attached for visualisation.