D3plot — LASSO Python Library

# D3plot

class `lasso.dyna.D3plot.` `D3plot`(filepath: str = None, use_femzip: bool = False, n_files_to_load_at_once=-1, state_array_filter=None)

  Constructor for a D3plot

  Parameters
    filepathstr

      path to a d3plot file

    use_femzipbool

      whether to use femzip decompression

    n_files_to_load_at_onceint

      number of d3plot files to load into memory at once. By default -1 means all are loaded

    state_array_filterlist of str or None

      names of arrays which will be the only ones loaded from state data

    Notes
    —–

      If dyna wrote multiple files for several states, only give the path to the first file.

  Attributes
    `arrays`

      Dictionary holding all d3plot arrays

    `header`

      Dictionary holding all d3plot header information

  Methods

  `compare`(self, d3plot2, array_eps, …) | Compare two d3plots and print the info
  `enable_logger`(enable) | Enable the logger for this class
  `get_part_filter`(self, filter_type, part_ids, …) | Get a part filter for different entities
  `plot`(self, i_timestep[, field]) | Plot the d3plot geometry
  `write_d3plot`(self, filepath, block_size_bytes) | Write a d3plot file again

  `__init__`(self, filepath: str = None, use_femzip: bool = False, n_files_to_load_at_once=-1, state_array_filter=None)

    Constructor for a D3plot

    Parameters
      filepathstr

        path to a d3plot file

      use_femzipbool

        whether to use femzip decompression

      n_files_to_load_at_onceint

        number of d3plot files to load into memory at once. By default -1 means all are loaded

      state_array_filterlist of str or None

        names of arrays which will be the only ones loaded from state data

      Notes
      —–

        If dyna wrote multiple files for several states, only give the path to the first file.

  property `arrays`

    Dictionary holding all d3plot arrays

    Notes

    The corresponding keys of the dictionary can also be found in lasso.dyna.ArrayTypes, which helps with IDE integration and code safety.

    Examples

        >>> d3plot = D3plot("some/path/to/d3plot")
        >>> d3plot.arrays.keys()
        dict_keys(['irbtyp', 'node_coordinates', ...])
        >>> # The following is good coding practice
        >>> import lasso.dyna.ArrayTypes.ArrayTypes as atypes
        >>> d3plot.arrays[atypes.node_displacmeent].shape

  `compare`(self, d3plot2, array_eps: Union[float, NoneType] = None)

    Compare two d3plots and print the info

    Parameters
      d3plot2D3plot

        second d3plot

      array_epsfloat or None

        tolerance for arrays, None by default

    Returns
      hdr_differencesdict

        differences in the header

      array_differencesdict

        difference between arrays (number of non-matching elements)

  static `enable_logger`(enable: bool)

    Enable the logger for this class

    Parameters
      enablebool

        whether to enable logging for this class

  `get_part_filter`(self, filter_type: lasso.dyna.FilterType.FilterType, part_ids: Iterable[int], for_state_array: bool = True) → numpy.ndarray

    Get a part filter for different entities

    Parameters
      filter_type: `lasso.dyna.FilterType` or `str`

        the array type to filter (beam, shell, solid, tshell)

      part_ids: `Iterable[int]`

        part ids to filter out

      for_state_array: `bool`

        if the filter is meant for a state array. Makes a difference for shells if rigid bodies are in the model (mattyp == 20)

    Returns
      mask: np.ndarray

        mask usable on arrays to filter results

    Examples

        >>> from lasso.dyna import D3plot, ArrayType, FilterType
        >>> d3plot = D3plot("path/to/d3plot")
        >>> part_ids = [13, 14]
        >>> mask = d3plot.get_part_filter(FilterType.shell)
        >>> shell_stress = d3plot.arrays[ArrayType.element_shell_stress]
        >>> shell_stress.shape
        (34, 7463, 3, 6)
        >>> # select only parts from part_ids
        >>> shell_stress_parts = shell_stress[:, mask]

  property `header`

    Dictionary holding all d3plot header information

    Notes

    The header contains many informations such as number of elements, etc. The names are the original dyna names, thus sometimes confusing … but that’s dyna.

    Examples

        >>> d3plot = D3plot("some/path/to/d3plot")
        >>> d3plot.header
        dict_keys(['title', 'runtime', 'filetype', 'source_version', ...])
        >>> # number of shells
        >>> d3plot.header['nel4']
        85624

  `plot`(self, i_timestep: int = 0, field=None, is_element_field: bool = True)

    Plot the d3plot geometry

    Parameters
      i_timestepint

        timestep index to plot

      fieldnp.ndarray

        Array containing a field value for every element

    Notes

    Currently only shell elements can be plotted, since for solids the surface needs extraction.

  `write_d3plot`(self, filepath: str, block_size_bytes: int = 2048)

    Write a d3plot file again

    Parameters
      filepathstr

        filepath of the new d3plot file

      block_size_bytesint

        D3plots are originally written in byte-blocks causing zero-padding at the end of files. This can be controlled by this parameter. Set to 0 for no padding.