/lsdyna_Keywords_parser

A Python parser for dealing 3D objects in LS DYNA Key Files

Primary LanguagePythonCreative Commons Zero v1.0 UniversalCC0-1.0

K_parser

Requirements

  • Python 3.7+
  • Provided with pip requirements list

Usage

usage: k_parser.py [-h] -f FILEPATHS [FILEPATHS ...]

optional arguments:
  -h, --help            show this help message and exit
  -f FILEPATHS [FILEPATHS ...], --filepaths FILEPATHS [FILEPATHS ...]
                        Input k files' ABSOLUTE filepaths

Example for two k_files:

% python3 k_parser.py -f /Users/danieljiang/Documents/UMTRI/UMTRI_M50/UMTRI_HBM_M50_V1.2_Nodes.k /Users/danieljiang/Documents/UMTRI/UMTRI_M50/UMTRI_HBM_M50_V1.2_Mesh_Components.k

Structure

References:

Functions & Examples

getNode

def getNode(self, nid: int) -> Tuple[float]

Returns (x,y,z)

getNodes

def getNodes(self, nids: list[int]=[]) -> list[Tuple[float]]:

Returns a list of coordinants

Example:

k_parser.getNodes([100000,100001])

Screen Shot 2022-10-20 at 09 27 34

getAllNodes

returns all nodes

Example:

Screen Shot 2022-10-20 at 16 10 59

getElementShell

def getElementShell(self, eid: int, outputType: int=0) -> Union[list[Tuple[float]], list[int]]:
    ''' Return the ELEMENT_SHELL given its ID

    Use outputType as:
        0 = list of coordinantes of the corresponding nodes
        1 = indices of the cooresponding nodes in self.nodes (better compatibility with vedo's
        mesh constructor)
    '''

Returns the ELEMENT_SHELL with different format options

Example:

k_parser.getElementShell(100005)

Screen Shot 2022-10-20 at 09 31 22

getPart

def getPart(self, pid: int, outputType: int=0) -> Union[list[list[Tuple[float]]], list[list[int]]]:
    ''' Return the PART given its ID

    Use outputType as:
        0 = list of list of coordinantes of the corresponding element shells.
            e.g. [[(x1,y1,z1),(x2,y2,z2),(x3,y3,z3)],[(x4,y4,z4)]] where p1,p2,p3 compose
            ELEMENT_SHELL1 and p4 composes ELEMENT_SHELL2
        1 = indices of the cooresponding nodes in self.nodes (better compatibility with vedo's
            mesh constructor)
            e.g. [[n1_ind,n2_ind,n3_ind],[n4_ind]]
    '''

Returns the part with different format options

Example:

k_parser.getPart(10003)

Screen Shot 2022-10-20 at 09 32 29

getAllParts

Get all parts

Screen Shot 2022-10-20 at 09 35 35