FEMFile (D3plot and KeyFile)

class qd.cae.dyna.FEMFile

Methods

get_elementByIndex(element_type, index)

Parameters

get_element_coords(element_filter)

Parameters

get_element_energy(element_filter)

Parameters

get_element_history_vars(element_type)

Parameters

get_element_ids(element_filter)

Parameters

get_element_node_ids(element_type, n_nodes)

Parameters

get_element_plastic_strain(element_filter)

Parameters

get_element_strain(element_filter)

Parameters

get_element_stress(element_filter)

Parameters

get_element_stress_mises(element_filter)

Parameters

get_elements([element_filter])

Parameters

get_filepath()

Returns

get_nElements([element_filter])

Parameters

get_nNodes()

Returns

get_nParts()

Returns

get_nodeByID(id)

Parameters

get_nodeByIndex(index)

Parameters

get_node_acceleration()

Returns

get_node_coords()

Returns

get_node_ids()

Returns

get_node_velocity()

Returns

get_nodes()

Returns

get_partByID(id)

Parameters

get_partByIndex(index)

Parameters

get_partByName(name)

Parameters

get_parts()

Returns

get_elementByID

get_elementByIndex(element_type, index)
Parameters
element_typeElement.type

type of the element. Must be beam, shell or solid.

indexint or list(int)

element index or list of indexes

Returns
elementElement

Element(s) depending on the arguments

Raises
ValueError

if invalid element_type is given or index does not exist

Examples

>>> # single element
>>> elem = femfile.get_elementByIndex(Element.shell, 0)
>>> # multiple elements
>>> list_of_shells = femfile.get_elementByID(Element.shell, [0,1,2])
>>> 
>>> femfile.get_elementByIndex(Element.beam, 1).get_type()
type.beam
>>> femfile.get_elementByIndex(Element.solid, 1).get_type()
type.solid
>>> femfile.get_elementByIndex(Element.tshell, 1).get_type()
type.tshell
get_element_coords(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

coords vector of the elements (nElems x nTimesteps x 3)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="coords")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_element_coords(Element.shell).shape
(4969, 32. 3)
get_element_energy(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

energy of the elements (nElems x nTimesteps)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="energy mean")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_element_energy(Element.shell).shape
(4969, 32)
get_element_history_vars(element_type)
Parameters
element_typeElement.type

type of the element

Returns
fieldnp.ndarray

history_vars vector of the elements (nElems x nTimesteps x nHistoryVars)

Notes

IMPORTANT: You can not query the history vars without specifying an element type. In LS-Dyna e.g. history var 7 is different between shells and beams. To prevent wrong usage and bugginess, we enforce this policy here. We didn’t mess this one up!

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="shell history 7 max")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> # Element type is required here!
>>> d3plot.get_element_history_vars(Element.shell).shape
(4969, 32. 10)
get_element_ids(element_filter)
Parameters
element_filterElement.type

optional element type for filtering

Returns
element_idsnp.ndarray

Ids of the elements

Notes

If the ids for all elements are queried (Element.none as filter type) then the returned order is:

  • Element.beam

  • Element.shell

  • Element.solid

  • Element.tshell

Examples

>>> d3plot = D3plot("path/to/d3plot")
>>> # get all ids (beam, shell, solid, tshell)
>>> d3plot.get_element_ids()
array([4687, 4688, 4689, 4690, ...])
>>> # filter only beams
>>> d3plot.get_element_ids(Element.beam)
array([9545, 9546, 9547, 9511, ...])
get_element_node_ids(element_type, n_nodes)
Parameters
element_typeElement.type

type of the element

n_nodesint

number of nodes

Returns
element_node_idsnp.ndarray

ids of the nodes for every element (shape elems x n_nodes).

Notes

The number of nodes must be specified since elements of one type may have different number of nodes which would result in a non-uniform matrix.

Examples

>>> d3plot = D3plot("path/to/d3plot")
>>> d3plot.get_element_node_ids(Element.shell, 4)
array([[347, 354, 343, 344],
       [354, 355, 342, 343],
       [349, 352, 356, 348]], dtype=int32)
get_element_plastic_strain(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

effective plastic strain of the elements (nElems x nTimesteps)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="plastic_strain max")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_plastic_strain(Element.shell).shape
(4969, 32)
get_element_strain(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

strain vector of the elements (nElems x nTimesteps x 6)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="strain mean")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_element_strain(Element.shell).shape
(4969, 32. 6)
get_element_stress(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

stress vector of the elements (nElems x nTimesteps x 6)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="stress mean")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_element_stress(Element.shell).shape
(4969, 32. 6)
get_element_stress_mises(element_filter)
Parameters
element_filterElement.type

optional type for filtering

Returns
fieldnp.ndarray

mises stress of the elements (nElems x nTimesteps)

Notes

If an element does not have the respective result, 0 is set as default value.

Examples

>>> d3plot = D3plot("path/to/d3plot", read_states="stress_mises mean")
>>> d3plot.get_nElements(Element.shell)
4969
>>> d3plot.get_nTimesteps()
32
>>> d3plot.get_element_stress_mises(Element.shell).shape
(4969, 32)
get_elements(element_filter=Element.none)
Parameters
element_filterElement.type

Optional element type filter. May be beam, shell or solid.

Returns
elementslist(Element)

list of Elements

Raises
ValueError

if invalid element_filter is given.

Notes

Get the elements of the femfile. One may use a filter by type.

Examples

>>> all_elements = femfile.get_elements()
>>> shell_elements = femfile.get_elements(Element.shell)
get_filepath()
Returns
filepathstr

Filepath of the femfile.

Examples

>>> femfile.get_filepath()
"path/to/femfile"
get_nElements(element_filter=Element.none)
Parameters
element_filterElement.type

Optional element type filter. May be beam, shell or solid.

Returns
nElementsint

number of elements

Raises
ValueError

if invalid element_filter is given.

Examples

>>> femfile.get_nElements()
43156
get_nNodes()
Returns
nNodesint

number of nodes in the file

Examples

>>> femfile.get_nNodes()
43145
get_nParts()
Returns
nPartsint

number of parts in the database

Examples

>>> femfile.get_nParts()
7
get_nodeByID(id)
Parameters
idint or list(int)

node id or list of node ids

Returns
nodeNode or list(Node)

requested Node(s)

Raises
ValueError

if idx does not exist.

Examples

>>> # get by single id
>>> node = femfile.get_nodeByID(1)
>>> # get a list of nodes at once
>>> list_of_nodes = femfile.get_nodeByID( [1,2,3] )
get_nodeByIndex(index)
Parameters
indexint or list(int)

internal node index or list inf indexes

Returns
nodeNode or list(Node)

Node(s)

Raises
ValueError

if index larger femfile.get_nNodes().

Notes

The internal index starts at 0 and ends at femfile.get_nNodes().

Examples

>>> # single index
>>> node = femfile.get_nodeByIndex(1)
>>> # get a list of nodes at once
>>> list_of_nodes = femfile.get_nodeByIndex( [1,2,3] )
get_node_acceleration()
Returns
node_accelerationnp.ndarray

Accelration of all nodes

Examples

>>> d3plot.get_node_acceleration().shape
(4915,1,3)
get_node_coords()
Returns
node_coordsnp.ndarray

coordinates of all nodes

Examples

>>> d3plot.get_node_coords().shape
(4915, 3)
get_node_ids()
Returns
node_idsnp.ndarray

Ids of all nodes

Examples

>>> d3plot.get_node_ids().shape
(100001)
get_node_velocity()
Returns
node_velocitynp.ndarray

Velocity of all nodes

Examples

>>> d3plot.get_node_velocity().shape
(4915,1,3)
get_nodes()
Returns
nodeslist(Node)

list of node objects

Examples

>>> list_of_nodes = femfile.get_nodes()
get_partByID(id)
Parameters
idint or list of int

id or ids of the part in the file

Returns
partsPart or list of Parts

output depending on arguments

Raises
ValueError

if some id does not exist.

Examples

>>> part = femfile.get_partByID(1)
get_partByIndex(index)
Parameters
indexint or list of int

index or indexes of the part in the file

Returns
partsPart or list of Parts

output depending on arguments

Raises
ValueError

if some index does not exist.

Examples

>>> part = femfile.get_partByIndex(0)
get_partByName(name)
Parameters
namestr

name of the part

Returns
partsPart

part with the given name

Raises
ValueError

if a part with name does not exist.

Examples

>>> part = femfile.get_partByName("Lower Bumper")
get_parts()
Returns
partslist(Part)

list of all parts in the file

Examples

>>> list_of_all_parts = femfile.get_parts()