RawD3plot

A RawD3plot is reading all of the raw data within a d3plot file. In contrast to the other D3plot class does it give access to the unprocessed data within the file.

There are two purposes why this class was created. Firstly one can use and check the raw data oneself and do all kind of magic things with it. Secondly not using object orientation should speed up the reading process by avoiding many small allocations.

The downside of the raw data access is the raw data itself. A d3plot has a very confusing structure. The file sometimes omits certain array elements and builds arrays in a very strange manner. Because the raw data arrays can be very confusing, one should not use this class without the official LS-Dyna database guide.

This class is not finished and will change! The raw data arrays are simply too confusing and need a further utility layer.


These are all the data arrays available with their shape description. They are categorized according to the variable type.

Float Data:
  • timesteps (nTimesteps)

  • node_coordinates (nNodes x 3)

  • node_displacement (nTimesteps x nNodes x 3)

  • node_velocity (nTimesteps x nNodes x 3)

  • node_acceleration (nTimesteps x nNodes x 3)

  • node_mass_scaling (nTimesteps x nNodes)

  • elem_solid_results (nTimesteps x nSolids x nResults)

  • elem_solid_deletion_info (nTimesteps x nSolids)

  • elem_shell_results_layers (nTimesteps x nShells x nLayers x nResults)

  • elem_shell_results (nTimesteps x nShells x nResults)

  • elem_shell_deletion_info (nTimesteps x nShells)

  • elem_tshell_results_layers (nTimesteps x nTShells x nLayers x nResults)

  • elem_tshell_results (nTimesteps x nTShells x nResults)

  • elem_tshell_deletion_info (nTimesteps x nTShells)

  • elem_beam_results (nTimesteps x nBeams x nResults)

  • elem_beam_deletion_info (nTimesteps x nBeams)

  • airbag_geom_state_float_results (nTimesteps x nAirbags x nResults)

  • airbag_particle_float_results (nTimesteps x nParticles x nResults)

Integer Data:
  • node_ids (nNodes)

  • elem_solid_ids (nSolids)

  • elem_solid_data (nSolids x 9) (nodes and material)

  • elem_shell_ids (nShells)

  • elem_shell_data (nShells x 5) (nodes and material)

  • elem_tshell_ids (nTShells)

  • elem_tshell_data (nTShells x 9) (nodes and material)

  • elem_beam_ids (nBeams)

  • elem_beam_data (nBeams x 6) (nodes and material)

  • part_ids (nParts)

  • material_type_numbers (nMaterials)

  • airbag_geometry (nAirbags x 4 or 5)

  • airbag_variable_type_flag (internally used only)

  • airbag_geom_state_int_results (nTimesteps x nAirbags x 1)

  • airbag_particle_int_results (nTimesteps x nParticles x 3)

String Data:
  • part_names (nParts)

  • airbag_all_variable_names

  • airbag_geom_names (names for airbag_geometry)

  • airbag_geom_state_int_names (names for airbag_geom_state_int_results)

  • airbag_geom_state_float_names (names for airbag_geom_state_float_results)

  • airbag_particle_int_names (names for airbag_particle_int_results)

  • airbag_particle_float_names (names for airbag_particle_float_results)


class qd.cae.dyna.RawD3plot(filepath)

Create a RawD3plot file object

Parameters
filepathstr

path to either the (first) d3plot or a d3plot in hdf5 format

Returns
instanceRawD3plot
Raises
ValueError

in case of an invalid filepath or locked file

RuntimeError

if anything goes wrong (internal checks) during reading

Notes

The constructor first checks, if the file is a hdf5 file and then tries to open it as a casual D3plot. If LS-Dyna writes multiple files (one for each timestep), give the filepath to the first file. The library finds all other files. The class automatically reads all data!

Examples

>>> from qd.cae.dyna import RawD3plot
>>> # read an arbitrary d3plot
>>> raw_d3plot = RawD3plot("path/to/d3plot")
>>> #read femzip compressed file
>>> raw_d3plot = RawD3plot("path/to/d3plot.fz")
>>> # save file as HDF5
>>> raw_d3plot.save_hdf5("path/to/d3plot.h5")
>>> # open HDF5 d3plot
>>> raw_d3plot = RawD3plot("path/to/d3plot.h5")

Methods

get_raw_data(self, key)

Get a variable from its name

get_raw_keys(self)

Get the names of the raw data fields

info()

Prints a summary of the header data of the d3plot, which involves node info, element info, written state data and so forth.

save_hdf5(self, filepath[, overwrite, …])

Save the raw d3plot to HDF5

__init__(self, filepath)

Create a RawD3plot file object

Parameters
filepathstr

path to either the (first) d3plot or a d3plot in hdf5 format

Returns
instanceRawD3plot
Raises
ValueError

in case of an invalid filepath or locked file

RuntimeError

if anything goes wrong (internal checks) during reading

Notes

The constructor first checks, if the file is a hdf5 file and then tries to open it as a casual D3plot. If LS-Dyna writes multiple files (one for each timestep), give the filepath to the first file. The library finds all other files. The class automatically reads all data!

Examples

>>> from qd.cae.dyna import RawD3plot
>>> # read an arbitrary d3plot
>>> raw_d3plot = RawD3plot("path/to/d3plot")
>>> #read femzip compressed file
>>> raw_d3plot = RawD3plot("path/to/d3plot.fz")
>>> # save file as HDF5
>>> raw_d3plot.save_hdf5("path/to/d3plot.h5")
>>> # open HDF5 d3plot
>>> raw_d3plot = RawD3plot("path/to/d3plot.h5")
_get_float_data(name)

For internal usage

This function is for reading any data, which is saved as a floating point value.

Parameters
namestr

name of data array to request for

Returns
datanumpy.ndarray

data array

Examples

>>> raw_d3plot.get_float_names()
['elem_shell_results', 'elem_shell_results_layers', 'elem_solid_results', ... ]
>>> raw_d3plot.get_float_data("elem_shell_results").shape
(12, 4696, 24)
>>> # 12 timesteps, 4969 elements and 24 variables
_get_float_names()
Returns
nameslist of str

names of all float variables in the d3plot

Examples

>>> raw_d3plot.get_float_names()
['elem_shell_results', 'elem_shell_results_layers', 'elem_solid_results', ... ]
_get_int_data(name)

For internal usage

This function is for reading any data, which is saved as an integer value.

namestr

name of data array to request for

Returns
datanumpy.ndarray

data array

Examples

>>> # check which vars are available
>>> raw_d3plott.get_int_names();
['elem_beam_data', 'elem_beam_ids', 'elem_shell_data', 'elem_shell_ids', ...]
>>> # request some data
>>> raw_d3plot.get_int_data("elem_shell_data").shape
(4969, 5)
>>> # 4969 shell elements, 4 node ids and 1 material index (not id!)
_get_int_names()

For internal usage

Returns
nameslist of str

names of the integer variables in the d3plot

Notes

The variable arrays themselves can be obtained by the member function ‘RawD3plot.get_int_data’.

Examples

>>> raw_d3plot.get_int_names();
['elem_beam_data', 'elem_beam_ids', 'elem_shell_data', 'elem_shell_ids', ...]
_get_string_data(name)

For internal usage

This function is for reading any data, which is saved as a string in the d3plot.

namestr

name of data array to request for

Returns
datalist of str

string data list

Examples

>>> raw_d3plot.get_string_names()
['part_names']
>>> # also the part names are raw (untrimmed)
>>> raw_d3plot.get_string_data("part_names")
["SomePart                                                                ']
_get_string_names()

For internal usage

Returns
nameslist of str

names of all string variables in the d3plot

Examples

>>> raw_d3plot.get_string_names()
['part_names']
_is_hdf5(self, filepath)

Check if a file is a HDF5 file

Parameters
filepathstr

path to the file

Returns
is_hdf5bool
_load_hdf5(self, filepath)

Load a d3plot, which was saved as an HDF5 file

Parameters
filepathstr

path to the d3plot in HDF5 format

get_raw_data(self, key)

Get a variable from its name

Parameters
keystr

name of the array or variable to get

Returns
datanp.ndarray or list

data array or list

Raises
ValueError

In case that the key can not be found or the arugment is not a str.

Examples

>>> shell_geom_data = raw_d3plot.get_raw_data("elem_shell_data")
get_raw_keys(self)

Get the names of the raw data fields

Returns
nameslist of str
info()

Prints a summary of the header data of the d3plot, which involves node info, element info, written state data and so forth.

Examples

>>> raw_d3plot = RawD3plot("path/to/d3plot")
>>> raw_d3plot.info()
save_hdf5(self, filepath, overwrite=True, compression='gzip')

Save the raw d3plot to HDF5

Raises
IOError

In case anything related to IO goes wrong.

Notes

Saves the data arrays from a D3plot into an HDF5 file.

Examples

>>> raw_d3plot = D3plot("path/to/d3plot")
>>> raw_d3plot.save_hdf5("path/to/d3plot.h5)