bdf/utils Package

This is the pyNastran.bdf.rst file.

utils Module

Defines various utilities including:
  • parse_patran_syntax
  • parse_patran_syntax_dict
  • Position
  • PositionWRT
  • TransformLoadWRT
pyNastran.bdf.utils.Position(xyz, cid, model, is_cid_int=None)[source]

Gets the point in the global XYZ coordinate system.

Parameters:
xyz : (3,) ndarray

the position of the GRID in an arbitrary coordinate system

cid : int

the coordinate ID for xyz

model : BDF()

the BDF model object

is_cid_int : bool

is cid/cid_new an integer or a Coord object (deprecated)

Returns:
xyz2 : (3,) ndarray

the position of the GRID in an arbitrary coordinate system

pyNastran.bdf.utils.PositionWRT(xyz, cid, cid_new, model, is_cid_int=None)[source]

Gets the location of the GRID which started in some arbitrary system and returns it in the desired coordinate system

Parameters:
xyz : (3, ) float ndarray

the position of the GRID in an arbitrary coordinate system

cid : int

the coordinate ID for xyz

cid_new : int

the desired coordinate ID

model : BDF()

the BDF model object

is_cid_int : bool

is cid/cid_new an integer or a Coord object (deprecated)

Returns:
xyz_local : (3, ) float ndarray

the position of the GRID in an arbitrary coordinate system

pyNastran.bdf.utils.TransformLoadWRT(F, M, cid, cid_new, model, is_cid_int=None)[source]

Transforms a force/moment from an arbitrary coordinate system to another coordinate system.

Parameters:
Fxyz : (3, ) float ndarray

the force in an arbitrary coordinate system

Mxyz : (3, ) float ndarray

the moment in an arbitrary coordinate system

cid : int

the coordinate ID for xyz

cid_new : int

the desired coordinate ID

model : BDF()

the BDF model object

is_cid_int : bool

is cid/cid_new an integer or a Coord object (deprecated)

Returns:
Fxyz_local : (3, ) float ndarray

the force in an arbitrary coordinate system

Mxyz_local : (3, ) float ndarray

the force in an arbitrary coordinate system

pyNastran.bdf.utils.parse_patran_syntax(node_sets, pound=None)[source]

Parses Patran’s syntax for compressing nodes/elements

Parameters:
node_sets : str

the node_set to parse

pound : int / str

value : the pound value (e.g. # in 1:#, which means all)

Returns:
nodes : List[int]

the integer values

Patran has a short syntax of the form:
String Output
“1 2 3” [1, 2, 3]
“5:10” [5, 6, 7, 8, 9, 10]
“12:20:2” [12, 14, 16, 18, 20]

Examples

Example 1

>>> node_sets = "1 2 3 5:10 12:20:2"
>>> data = parse_patran_syntax(node_sets)
>>> data
data = [1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20]

Example 2

>>> node_sets = "1 2 3:#"
>>> data = parse_patran_syntax(node_sets, pound=10)
>>> data
data = [1, 2, 3, 5, 6, 7, 8, 9, 10]

Warning

Don’t include the n/node or e/element or any other identifier, just a string of “1 2 3 5:10 12:20:2”. Use parse_patran_syntax_dict to consider the identifier.

pyNastran.bdf.utils.parse_patran_syntax_dict(node_sets, pound_dict=None, msg='')[source]

Parses Patran’s syntax for compressing nodes/elements

Parameters:
node_sets : str

the node_set to parse

pound_dict : List[str]

key : the string value : the pound value (e.g. 1:#)

msg : str

error message; currently unused

Returns:
nodes : Dict[str] = List[int]

str : the key values : the integer values for that key

Notes

An identifier (e.g. “e”) must be used. Use parse_patran_syntax to skip the identifier.

Warning

case sensitive

Examples

Example 1

>>> node_sets = "e 1:3 n 2:6:2 Node 10:13"
>>> data = parse_patran_syntax_dict(node_sets)
>>> data = {
      'e'    : [1, 2, 3],
      'n'    : [2, 4, 6],
      'Node' : [10, 11, 12, 13],
}

Example 2

>>> node_sets = "e 1:3 n 2:6:2 Node 10:#"

# a pound character will be set to 20, but only for ‘Node’, but not # ‘n’ so define it twice if needed >>> pounds = {‘Node’ : 20} >>> data = parse_patran_syntax_dict(node_sets, pounds=pounds) >>> data = {

‘e’ : [1, 2, 3], ‘n’ : [2, 4, 6], ‘Node’ : [10, 11, 12, 13],

}

pyNastran.bdf.utils.parse_patran_syntax_dict_map(node_sets, type_map, msg='')[source]

Parses Patran’s syntax for compressing nodes/elements

Parameters:
node_sets : str

the node_set to parse

type_map : dict[key_in]
key_in : str

the name of the input string

key_out : str

the name of the out string

#pound_dict : List[str]

#key : the string #value : the pound value (e.g. 1:#)

msg : str

error message; currently unused

Returns:
nodes : Dict[str] = List[int]

str : the key values : the integer values for that key

Examples

Example 1 .. code-block:: python

# we drop the coordinate systems because we didn’t request them # (coord is not referenced) # >>> node_sets = “e 1:3 n 2:6:2 Node 10:13 N 15 coord 1:10” >>> type_map = {

‘n’ : ‘Node’, ‘Node’ : ‘Node’, ‘e’ : ‘Element’, ‘Elm’ : ‘Element’, ‘Element’ : ‘Element’,

}

Example 2 >>> data = parse_patran_syntax_dict(node_sets, type_map) >>> data = {

‘Element’ : [1, 2, 3], ‘Node’ : [2, 4, 6, 10, 11, 12, 13, 15],

}

Todo

doesn’t support pound_dict

pyNastran.bdf.utils.split_eids_along_nids(model, eids, nids)[source]

Dissassociate a list of elements along a list of nodes.

The expected use of this function is that you have two bodies that are incorrectly equivalenced and you would like to create duplicate nodes at the same location and associate the new nodes with one half of the elements.

Pick the nodes along the line and the elements along one side of the line.

Parameters:
model : BDF()

the BDF model

eids : list/tuple

element ids to disassociate

nids : list/tuple

node ids to disassociate

Implicitly returns model with additional nodes.

Notes

xref should be set to False for this function.

pyNastran.bdf.utils.transform_load(F, M, cid, cid_new, model)[source]

Transforms a force/moment from an arbitrary coordinate system to another coordinate system.

Parameters:
Fxyz : (3, ) float ndarray

the force in an arbitrary coordinate system

Mxyz : (3, ) float ndarray

the moment in an arbitrary coordinate system

cid : int

the coordinate ID for xyz

cid_new : int

the desired coordinate ID

model : BDF()

the BDF model object

Returns:
Fxyz_local : (3, ) float ndarray

the force in an arbitrary coordinate system

Mxyz_local : (3, ) float ndarray

the force in an arbitrary coordinate system

pyNastran.bdf.utils.write_patran_syntax_dict(dict_sets)[source]

writes partran syntax

Parameters:
dict_sets : Dict[str] = List[int]

str : the key values : the integer values for that key

Returns:
node_sets : str

the node_set to parse

See parse_patran_syntax_dict for explanation of usage

write_path Module

Defines following useful methods:
  • write_include(filename, is_windows=True)
pyNastran.bdf.write_path._split_path(abspath, is_windows)[source]

Takes a path and splits it into the various components.

This is a helper method for write_include

pyNastran.bdf.write_path.write_include(filename, is_windows=None)[source]

Writes a bdf INCLUDE file line given an imported filename.

Parameters:
filename : str

the filename to write

is_windows : bool; default=None
True/False : Windows has a special format for writing INCLUDE

files, so the format for a BDF that will run on Linux and Windows is different.

None : Check the platform

For a model that will run on Linux:
..code-block:: python

fname = r’/opt/NASA/test1/test2/test3/ test4/formats/pynastran_v0.6/pyNastran/bdf/model.inc’ write_include(fname, is_windows=False)

We want:
..code-block:: python
INCLUDE /opt/NASA/test1/test2/test3/test4/formats/pynastran_v0.6/

pyNastran/bdf/model.inc