fieldinterpmesh.py¶
- class FieldInterpMesh(sim_data, comp_keys, spatial_dims)[source]¶
Bases:
IFieldInterpClass for interpolating mesh-based simulation fields to the virtual sensor locations and sample times. Note that mesh-based data includes a connectivity table in the underlying SimData object.
Implements the IFieldInterp interface.
- __init__(sim_data, comp_keys, spatial_dims)[source]¶
- Parameters:
sim_data (
mh.SimData) – Simulation data object containing the physical field(s) that the virtual sensors will sample.comp_keys (
tuple[str,...]) – Tuple of string keys for the components of the field(s) to be interpolated.spatial_dims (
EDim) – Enumeration used to determine the number of spatial dimensions of the simulation to determine the underlying element types in the mesh.
- interp_field(points, sample_times=None)[source]¶
Invokes the field interpolation algorithm at the given points and sample times. Spatial interpolation is performed first at existing data time steps. If the sample times are the same as the underlying data no temporal interpolation is performed otherwise linear interpolation is performed between time steps for each point in space.
- Parameters:
points (
np.ndarray) – Array of points to spatially interpolate the physical field to.sample_times (
np.ndarray | None, optional) – Vector of times at which to sample the underlying physical field, by default None. If this is None then no temporal interpolation is performed and the points returned correspond to the input simulation time steps.
- Returns:
np.ndarray– Simulated measurement array intepolated from the simulation data to the desired sensor locations and sample times with shape=( num_sensors,num_field_components,num_sample_times).
- sample_pyvista_grid(comp_keys, pyvista_interp, sim_time_steps, points, sample_times=None)[source]¶
Function for sampling (interpolating) a pyvista grid object containing simulated field data. The pyvista sample method uses VTK to perform the spatial interpolation using the element shape functions. If the sampling time steps are not the same as the simulation time then a linear interpolation over time is performed using numpy.
NOTE: sampling outside the mesh bounds of the sample returns a value of 0.
- Parameters:
comp_keys (
tuple[str,...]) – String keys for the comp_keys to be sampled in the pyvista grid object. Useful for only interpolating the field comp_keys of interest for speed and memory reduction.pyvista_interp (
pv.UnstructuredGrid) – Pyvista grid object containing the simulation mesh and the comp_keys of the physical field that will be sampled.sim_time_steps (
np.ndarray) – Simulation time steps corresponding to the fields in the pyvista grid object.points (
np.ndarray) – Coordinates of the points at which to sample the pyvista grid object. shape=(num_points,3) where the columns are the X, Y and Z coordinates of the sample points in simulation world coordintes.sample_times (
np.ndarray | None, optional) – Array of time steps at which to sample the pyvista grid. If None then no temporal interpolation is performed and the sample times are assumed to be the simulation time steps.
- Returns:
np.ndarray– Array of sampled sensor measurements with shape=(num_sensors, num_field_comp_keys,num_time_steps).