simtools.py

class SimTools[source]

Bases: object

static print_dataclass_fields(in_data)[source]

Diagnostic function

Parameters:

in_data (Any) – A data class to print the type and fields for as well as the type of each of the fields.

static print_sim_data(sim_data)[source]

Diagnostic function for inspecting a sim data object to work out shapes of time, coordinates, connectivity tables, node vars, elem vars as well as the associated keys in the dicttionaries for the connectivity, node/elem/glob vars.

Parameters:

sim_data (mh.SimData) – SimData to print shapes of numpy arrays.

static print_dimensions(sim_data)[source]

Diagnostic function for quickly finding the coordinate limits for from a given simulation.

Parameters:

sim_data (mh.SimData) – Simulation data object containing the nodal coordinates.

static get_sim_dims(sim_data)[source]

Diagnostic function for extracting the dimensional limits in space and time from a SimData object. Useful for finding the spatial dimensions over which simulated sensors can be placed as well as the times over which they can sampled the underlying field.

Parameters:

sim_data (mh.SimData) – Simulation data object containing the coordinates and time steps.

Returns:

dict[str,tuple[float,float]] – Dictionary of space and time coordinate limits keyed as ‘x’,’y’,’z’ for the spatial dimensions and ‘t’ for time. The dictionary will return a tuple with the (min,max) of the given dimension.

static centre_mesh_nodes(nodes, spat_dim)[source]

A method to centre the nodes of a mesh around the origin.

Parameters:
  • nodes (np.ndarray) – An array containing the node locations of the mesh.

  • spat_dim (int) – The spatial dimension of the mesh.

Returns:

np.ndarray – An array containing the mesh node locations, but centred around the origin.

static get_deformed_nodes(timestep, render_mesh)[source]
A method to obtain the deformed locations of all the nodes at a given

timestep.

Parameters:
  • timestep (int) – The timestep at which to find the deformed nodes.

  • render_mesh (RenderMeshData) – A dataclass containing the skinned mesh and simulation results.

Returns:

np.ndarray | None – An array containing the deformed values of all the components at each node location. Returns None if there are no deformation values.