The writer_utils.py module#
Summary#
Create node keyword from a NumPy array of nodes. |
|
Add nodes to an existing *NODE keyword. |
|
Add beams to an existing *ELEMENT_BEAM keyword. |
|
Create a segment set keyword from an array with the segment set definition. |
|
Create a nodeset. |
|
Create an element shell keyword. |
|
Format the *ELEMENT_SOLID keyword with the provided input. |
|
Format the *ELEMENT_SOLID_ORTHO keyword with the provided input. |
|
Create define curve from x and y values. |
|
Create define SD orientation keyword. |
|
Create discrete elements based on input arguments. |
|
Get array of used IDs in the database. |
|
Fast implementation of the element writer. |
Description#
Module for useful methods to help format LS-DYNA keywords.
Module detail#
- writer_utils.create_node_keyword(nodes: numpy.ndarray, offset: int = 0) ansys.dyna.core.keywords.keywords.Node#
Create node keyword from a NumPy array of nodes.
- Parameters:
- nodes
np.ndarray NumPy array containing the node coordinates.
- nodes
- Returns:
keywords.NodeFormatted node keyword.
- writer_utils.add_nodes_to_kw(nodes: numpy.ndarray, node_kw: ansys.dyna.core.keywords.keywords.Node, offset: int = 0) ansys.dyna.core.keywords.keywords.Node#
Add nodes to an existing *NODE keyword.
- Parameters:
- nodes
np.ndarray NumPy array of node coordinates to add. If (n,3), the node ID is continuous by offset. If (n,4), the first column is the node ID.
- node_kw
keywords.Node Node keyword.
- offset
int Node ID offset.
- nodes
Notes
If nodes are already defined, this method adds both the nodes in the previous keyword and the specified array of nodes. It automatically computes the index offset in case
node_kw.nodesis not empty.
- writer_utils.add_beams_to_kw(beams: numpy.ndarray, beam_kw: ansys.dyna.core.keywords.keywords.ElementBeam, pid: int, offset: int = 0) ansys.dyna.core.keywords.keywords.ElementBeam#
Add beams to an existing *ELEMENT_BEAM keyword.
- Parameters:
- beams
np.ndarray NumPy array of beam coordinates to add.
- beam_kw
keywords.ElementBeam Beam keyword.
- offset
int Beam ID offset.
- beams
Notes
If beams are already defined, this method adds both the beams in the previous keyword and the specified array of beams. It automatically computes the index offset in case
beam_kw.elementsis not empty.
- writer_utils.create_segment_set_keyword(segments: numpy.ndarray, segid: int = 1, title: str = '') ansys.dyna.core.keywords.keywords.SetSegment#
Create a segment set keyword from an array with the segment set definition.
- writer_utils.create_node_set_keyword(node_ids: numpy.ndarray | list[int] | int, node_set_id: int = 1, title: str = 'nodeset-title') ansys.dyna.core.keywords.keywords.SetNodeList#
Create a nodeset.
- writer_utils.create_element_shell_keyword(shells: numpy.ndarray, part_id: int = 1, id_offset: int = 0) ansys.dyna.core.keywords.keywords.ElementShell#
Create an element shell keyword.
Notes
This method creates an element shell keyword from a NumPy array of elements. Each row corresponds to an element.
- writer_utils.create_element_solid_keyword(elements: numpy.ndarray, e_id: numpy.ndarray, part_id: numpy.ndarray, element_type: str = 'tetra') ansys.dyna.core.keywords.keywords.ElementSolid#
Format the *ELEMENT_SOLID keyword with the provided input.
- writer_utils.create_element_solid_ortho_keyword(elements: numpy.ndarray, a_vec: numpy.ndarray, d_vec: numpy.ndarray, e_id: numpy.ndarray, part_id: numpy.ndarray, element_type: str = 'tetra') ansys.dyna.core.keywords.keywords.ElementSolidOrtho#
Format the *ELEMENT_SOLID_ORTHO keyword with the provided input.
- Parameters:
- elements
np.ndarray NumPy array of integers with element definition
- a_vec
np.ndarray Vector specifying the A direction.
- d_vec
np.ndarray Vector specifying the D direction.
- part_id
np.ndarray Part IDs of each element.
- e_id
np.ndarray Element ID.
- element_type
str, default:'tetra' Type of element to write.
- elements
- Returns:
keywords.ElementSolidOrthoFormatted *ELEMENT_SOLID_ORTHO keyword.
- writer_utils.create_define_curve_kw(x: numpy.ndarray, y: numpy.ndarray, curve_name: str = 'my-title', curve_id: int = 1, lcint: int = 15000) ansys.dyna.core.keywords.keywords.DefineCurve#
Create define curve from x and y values.
- writer_utils.create_define_sd_orientation_kw(vectors: numpy.ndarray, vector_id_offset: int = 0, iop: int = 0) ansys.dyna.core.keywords.keywords.DefineSdOrientation#
Create define SD orientation keyword.
- writer_utils.create_discrete_elements_kw(nodes: numpy.ndarray, part_id: int, vector_ids: numpy.ndarray | int, scale_factor: numpy.ndarray | float, element_id_offset: int = 0) ansys.dyna.core.keywords.keywords.ElementDiscrete#
Create discrete elements based on input arguments.
- Parameters:
- nodes
np.ndarray Nx2 array with node IDs used for the discrete element.
- part_id
int Part ID of the discrete elements given.
- vector_ids
np.ndarray|int Orientation IDs (vector IDs) that the spring acts on. You can provide either an array of length N or a scalar integer.
- scale_factor
np.ndarray|float Scale factor on forces. You can provide either an array of length N or a scalar value.
- element_id_offset
int, default: 0 Offset value for the element IDs.
- init_offset
float, default: 0.0 Initial offset, which is the initial displacement or rotation at t=0.
- nodes
- writer_utils.get_list_of_used_ids(keyword_db: ansys.dyna.core.Deck, keyword_str: str) numpy.ndarray#
Get array of used IDs in the database.
- Parameters:
- database
Deck Database of keywords.
- keyword
str Keyword to find.
- database
- Returns:
np.ndarrayArray of IDs (integers) that are already used
Notes
For example, for *SECTION, you would get *PART and *MAT IDs.