MeshDataset#

class MeshDataset(mesh, timing_ms)[source]#

This class bundles basic functionality to handles dynamic meshes and implements convenience functionality like rendering or slice selection.

Parameters:
  • mesh (Union[UnstructuredGrid, DataSet]) – pyvista mesh containing the field-array ‘displacement_{time}ms’ for each time specified in timing_ms

  • timing_ms (ndarray) – array containing the times corresponding to the stored displacements

Methods:

add_data_per_time(scalars, name)

Adds a scalar field array for each time-stamp

get_field(field_name[, timing_indices])

Gets the specified field at all given time-indices and returns a stacked array.

get_positions_at_time(time)

Returns mesh nodes at the closest match to time argument

get_trajectories(start, end[, string_cast])

Returns available times and positions between specified start-end

probe_reference(reference_mesh, field_names)

Probes the reference mesh with the points of self.mesh at reference time and stores the probed fields matching the given names into self.mesh.

render_input_animation(filename[, plotter, ...])

Renders an animation of the contained mesh using the displacements.

select_slice(slice_position, slice_normal, ...)

Filters all mesh nodes by position and returns an unstructured grid that contains

transform_vectors(time_stamps, vector_names)

Evalutes the deformation matrix for ref-timing -> time_stamps and applies the transformation to the vector arrays of specified names in the mesh.

Attributes:

mesh

Mesh containing the displacements for each time-point

timing

Time points corresponding to the mesh states given by the list of files in ms

add_data_per_time(scalars, name)[source]#

Adds a scalar field array for each time-stamp

Parameters:
  • scalars (array) – (t, #p, …)

  • name (str) – name of the scalar

get_field(field_name, timing_indices=None)[source]#

Gets the specified field at all given time-indices and returns a stacked array. Assumes the field to be stored as ‘{field_name}_{t}ms’.

Parameters:
  • field_name (str) – str

  • timing_indices (Iterable[int]) – integers indexing self.timing

Return type:

(Quantity, ndarray)

Returns:

get_positions_at_time(time)[source]#

Returns mesh nodes at the closest match to time argument

Parameters:

time (Quantity) – Quantity

Return type:

ndarray

Returns:

positions at given time

get_trajectories(start, end, string_cast=<class 'float'>)[source]#

Returns available times and positions between specified start-end

Parameters:
  • start (Quantity) – Quantity

  • end (Quantity) – Quantity

  • string_cast (callable) – callable to format the number to inserted as field name-time-stamp

Return type:

Tuple[Quantity, Quantity]

Returns:

time (t, ), positions (N, t, 3)

probe_reference(reference_mesh, field_names, reference_time=None)[source]#

Probes the reference mesh with the points of self.mesh at reference time and stores the probed fields matching the given names into self.mesh.

Parameters:
  • reference_mesh (UnstructuredGrid) –

  • field_names (List[str]) –

  • reference_time (Quantity) –

Returns:

render_input_animation(filename, plotter=None, scalar=None, vector=None, start=<Quantity(0.0, 'millisecond')>, end=None, mesh_kwargs=None, vector_kwargs=None, text_kwargs=None)[source]#

Renders an animation of the contained mesh using the displacements. Depending on specified arguments, renders vectors/scalars stored as ‘{name}_{t}ms’ in the mesh.

Parameters:
  • filename (str) – Filename/path where the result is stored

  • plotter (Plotter) – Optional - if specified, this pyvista.Plotter is used to render the animation

  • scalar (str) – Optional - if specified, the mesh is plotted using this scalar as color, assuming that for all time-stamps a scalar quantity is stored as field_data as ‘{name}_{t}ms’

  • vector (str) – Optional - if specified, additional vectors starting at mesh nodes are rendered, assuming that for all time-stamps a vector quantity is stored as field_data as ‘{name}_{t}ms’

  • start (Quantity) – Defines the start time for animation.

  • end (Quantity) – Defines the end time for animation.

  • mesh_kwargs (dict) – keyword arguments forwarded to plotter.add_mesh(…, **mesh_kwargs). See pyvista reference for more detail

  • vector_kwargs (dict) – defaults to {“mag”: 1e-3}. Keyword arguments forwarded to plotter.add_arrows(…, **vector_kwargs). See reference for more detail.

  • text_kwargs (dict) – defaults to dict(position=’upper_right’, color=’white’, shadow=False, font_size=26). Keyword arguments forwarded to plotter.add_text(…).

Return type:

None

select_slice(slice_position, slice_normal, slice_thickness, reference_time)[source]#
Filters all mesh nodes by position and returns an unstructured grid that contains

only the nodes within the specified slice definition at the reference.

Parameters:
  • slice_position (Quantity) – (3, ) vector denoting the slice position

  • slice_normal (ndarray) – (3, ) vector denoting the normal vector of the slice (is normalized internally)

  • slice_thickness (Quantity) – Thickness of the selected slice (along the slice_normal)

  • reference_time (Quantity) –

Return type:

UnstructuredGrid

Returns:

mesh containing only the cell being inside the specified slice

transform_vectors(time_stamps, vector_names, reference_time=None, rotation_only=True)[source]#

Evalutes the deformation matrix for ref-timing -> time_stamps and applies the transformation to the vector arrays of specified names in the mesh. Results are stored as vector field in self.mesh.

Parameters:
  • time_stamps (ndarray) –

  • vector_names (List[str]) – Names of properties that are transformed

  • reference_time (Quantity) – Time that correspond to the definition of the vectors

  • rotation_only (bool) – If true the transformation includes a normalization, thus results in a rotation only.

mesh: Union[UnstructuredGrid, DataSet]#

Mesh containing the displacements for each time-point

timing: ndarray#

Time points corresponding to the mesh states given by the list of files in ms