ElementKeyword

This class is used to manage elements of the KeyFile.

class qd.cae.dyna.ElementKeyword
Attributes
field_size

field_size

position

Notes —– Line index of the Keyword.

Methods

add_elementByNodeID(id, part_id, node_ids[, …])

Parameters

add_elementByNodeIndex(id, part_id, node_indexes)

Parameters

align

Type of alignment for comment names and fields:

append_line(line)

Parameters

get_card_valueByIndex(iCard, iField[, …])

Parameters

get_card_valueByName(name[, field_size])

Parameters

get_elements()

Returns

get_keyword_name()

Returns

get_line()

Parameters

get_lines()

Returns

get_nElements()

Returns

has_long_fields()

Returns

insert_line(iLine, line)

Parameters

load()

Notes

reformat_all([skip_cards])

Parameters

reformat_field(iCard, iField[, field_size, …])

Parameters

remove_line(iLine)

Parameters

set_card_valueByDict(fields[, field_size])

Parameters

set_card_valueByIndex(iCard, iField, value)

Parameters

set_card_valueByName(name, value[, field_size])

Parameters

set_line(iLine, line)

Parameters

set_lines(lines)

Parameters

switch_field_size([skip_cards])

Parameters

add_elementByNodeID(id, part_id, node_ids, additional_card_data="")
Parameters
idint

id of the new element

part_idint

id of the part to which this element shall be assigned

node_idslist of int

list of node ids, which belong to the element

additional_card_datastr or list of str

further card data (see Notes section).

Returns
elemElement

newly created element object

Notes

The additional_card_data is a string or a list of strings appended to the keyword when writing the output file. This is required in case a non-standard keyword is used such as *ELEMENT_BEAM_SCALAR, which requires further card infos. The first line or string is appended without a linebreak.

The type of the element is inferred from the name of the keyword.

Examples

>>> print(kw)
*ELEMENT_SHELL
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
>>> elem = kw.add_elementByNodeID(2, 1, [1,2,3])
>>> print(kw)
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
       2       1       1       2       3       3
add_elementByNodeIndex(id, part_id, node_indexes, additional_card_data="")
Parameters
idint

id of the new element

part_idint

id of the part to which this element shall be assigned

node_indexeslist of int

list of node indexes, which belong to the element

additional_card_datastr or list of str

further card data (see Notes section).

Returns
elemElement

newly created element object

Notes

The additional_card_data is a string or a list of strings appended to the keyword when writing the output file. This is required in case a non-standard keyword is used such as *ELEMENT_BEAM_SCALAR, which requires further card infos. The first line or string is appended without a linebreak.

The type of the element is inferred from the name of the keyword.

Examples

>>> print(kw)
*ELEMENT_SHELL
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
>>> elem = kw.add_elementByNodeIndex(2, 1, [0,1,2])
>>> print(kw)
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
       2       1      77      21       4       4
get_elements()
Returns
elementslist of Element

parsed elements belonging to the keyword

Notes

Get all elements of belonging to the keyword.

Examples

>>> print(kw)
*ELEMENT_SHELL
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
>>> len( kw.get_elements() )
1
get_nElements()
Returns
nElementsint

number of elements belonging to the keyword

Examples

>>> print(kw)
*ELEMENT_SHELL
$    eid     pid      n1      n2      n3      n4
       1       1       1       2       3       4
>>> kw.nElements()
1
load()

Notes

This function iterates through the lines of the keyword, parses each element and loads it the files database. In the process, the lines of every parsed element is destroyed.

Examples

>>> kf = KeyFile("path/to/keyfile",parse_mesh=True)
>>> kw = kf.add_keyword("*ELEMENT_SHELL")
>>> kw.get_nElements()
0
>>> # append a new element (id=3, part_id=1 and node ids)
>>> kw.append_line("       3       1       1       2       3       4")
>>> kw.load()
>>> kw.get_nElements()
1