fieldtensor¶
- class pyvale.fieldtensor.FieldTensor(sim_data: SimData, field_name: str, norm_comps: tuple[str, ...], dev_comps: tuple[str, ...], elem_dims: int)[source]¶
Bases:
IField
Class for sampling (interpolating) tensor fields from simulations to provide sensor values at specified locations and times.
Implements the IField interface.
- Parameters:
sim_data (mh.SimData) -- Simulation data object containing the mesh and field to interpolate.
field_name (str) -- String describing the tensor field. For example: 'strain'.
components (tuple[str,...]) -- String keys to the field components in the SimData object. For example ('stain_xx','strain_yy','strain_xy').
elem_dims (int) -- Number of spatial dimensions (2 or 3) used for identifying element types.
- get_all_components() tuple[str, ...] [source]¶
Gets the string keys for the component of the physical field. For example: a tensor field might have ('strain_xx','strain_yy','strain_xy') in 2D.
- Returns:
tuple[str,...] -- Tuple containing the string keys for all components of the physical field.
- get_component_index(comp: str) int [source]¶
Gets the index for a component of the physical field. Used for getting the index of a component in the sensor measurement array.
- Parameters:
component (str) -- String key for the field component (e.g. 'temperature' or 'disp_x').
- Returns:
int -- Index for the selected field component
- get_sim_data() SimData [source]¶
Gets the simulation data object associated with this field. Used by pyvale visualisation tools to display simulation data with simulated sensor values.
- Returns:
mh.SimData -- Mooseherder SimData object. Contains a mesh and a simulated physical field.
- get_time_steps() ndarray [source]¶
Gets a 1D array of time steps from the simulation data.
- Returns:
np.ndarray -- 1D array of simulation time steps. shape=(num_time_steps,)
- get_visualiser() UnstructuredGrid [source]¶
Gets a pyvista unstructured grid object for visualisation purposes.
- Returns:
pv.UnstructuredGrid -- Pyvista unstructured grid object containing only a mesh without any physical field data attached.
- sample_field(points: ndarray, times: ndarray | None = None, angles: tuple[Rotation, ...] | None = None) ndarray [source]¶
Samples (interpolates) the simulation field at the specified positions, times, and angles.
- Parameters:
points (np.ndarray) -- Spatial points to be sampled with the rows indicating the point number of the columns indicating the X,Y and Z coordinates.
times (np.ndarray | None, optional) -- Times to sample the underlying simulation. If None then the simulation time steps are used and no temporal interpolation is performed, by default None.
angles (tuple[Rotation,...] | None, optional) -- Angles to rotate the sampled values into with rotations specified with respect to the simulation world coordinates. If a single rotation is specified then all points are assumed to have the same angle and are batch processed for speed. If None then no rotation is performed, by default None.
- Returns:
np.ndarray -- An array of sampled (interpolated) values with the following dimensions: shape=(num_points,num_components,num_time_steps).
- set_sim_data(sim_data: SimData) None [source]¶
Sets the SimData object that will be interpolated to obtain sensor values. The purpose of this is to be able to apply the same sensor array to an array of different simulations by setting a different SimData.
- Parameters:
sim_data (mh.SimData) -- Mooseherder SimData object. Contains a mesh and a simulated physical field.