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:
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 containing the displacements for each time-point
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’.
- get_positions_at_time(time)[source]#
Returns mesh nodes at the closest match to time argument
- Parameters:
time (
Quantity
) – Quantity- Return type:
- 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
) – Quantityend (
Quantity
) – Quantitystring_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.
- 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 storedplotter (
Plotter
) – Optional - if specified, this pyvista.Plotter is used to render the animationscalar (
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 detailvector_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:
- 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 positionslice_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