bdf/utils Package¶
This is the pyNastran.bdf.rst file.
utils
Module¶
- Defines various utilities for BDF parsing including:
- to_fields
- parse_patran_syntax
- parse_patran_syntax_dict
- Position
- PositionWRT
- TransformLoadWRT
-
exception
pyNastran.bdf.utils.
CardParseSyntaxError
[source]¶ Class that is used for testing. Users should just treat this as a SyntaxError.
-
pyNastran.bdf.utils.
Position
(xyz, cid, model, is_cid_int=True)[source]¶ Gets the point in the global XYZ coordinate system.
Parameters: - xyz (TYPE = NDARRAY. SIZE=(3,)) – the position of the GRID in an arbitrary coordinate system
- cid (int) – the coordinate ID for xyz
- model (BDF()) – the BDF model object
Returns xyz2: the position of the GRID in an arbitrary coordinate system
-
pyNastran.bdf.utils.
PositionWRT
(xyz, cid, cid_new, model, is_cid_int=True)[source]¶ Gets the location of the GRID which started in some arbitrary system and returns it in the desired coordinate system
Parameters: - xyz (TYPE = NDARRAY. SIZE=(3,)) – 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
Returns xyz_local: the position of the GRID in an arbitrary coordinate system
-
pyNastran.bdf.utils.
TransformLoadWRT
(F, M, cid, cid_new, model, is_cid_int=True)[source]¶ Transforms a force/moment from an arbitrary coordinate system to another coordinate system.
Parameters: - Fxyz (TYPE = NDARRAY. SIZE=(3,)) – the force in an arbitrary coordinate system
- Mxyz (TYPE = NDARRAY. SIZE=(3,)) – 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
Returns Fxyz_local: the force in an arbitrary coordinate system
Returns Mxyz_local: the force in an arbitrary coordinate system
-
pyNastran.bdf.utils.
_clean_comment
(comment, end=-1)[source]¶ Removes specific pyNastran comment lines so duplicate lines aren’t created.
param comment: the comment to possibly remove param end: lets you remove trailing characters (e.g. a `` ``; default=-1)
-
pyNastran.bdf.utils.
clean_empty_lines
(lines)[source]¶ Removes leading and trailing empty lines don’t remove internally blank lines
-
pyNastran.bdf.utils.
get_include_filename
(card_lines, include_dir='')[source]¶ Parses an INCLUDE file split into multiple lines (as a list).
Parameters: - card_lines – the list of lines in the include card (all the lines!)
- include_dir – the include directory (default=’‘)
Returns filename: the INCLUDE filename
-
pyNastran.bdf.utils.
parse_executive_control_deck
(executive_control_lines)[source]¶ Extracts the solution from the executive control deck
-
pyNastran.bdf.utils.
parse_patran_syntax
(node_sets)[source]¶ Parses Patran’s syntax for compressing nodes/elements
Parameters: node_sets – the node_set to parse Returns nodes: list of integers 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]
-
pyNastran.bdf.utils.
parse_patran_syntax_dict
(node_sets)[source]¶ Parses Patran’s syntax for compressing nodes/elements
Parameters: node_sets – the node_set to parse Returns nodes: list of integers 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], }
Note
the identifier (e.g. “e”) must be used. Use parse_patran_syntax to skip the identifier.
Note
doesn’t support “1:#”
-
pyNastran.bdf.utils.
print_filename
(filename, relpath)[source]¶ Takes a path such as C:/work/fem.bdf and locates the file using relative paths. If it’s on another drive, the path is not modified.
Parameters: filename – a filename string Returns filename_string: a shortened representation of the filename
-
pyNastran.bdf.utils.
to_fields
(card_lines, card_name)[source]¶ Converts a series of lines in a card into string versions of the field. Handles large, small, and CSV formatted cards.
Parameters: - lines – the lines of the BDF card object
- card_name – the card_name -> ‘GRID’
Returns fields: the string formatted fields of the card
Warning
this function is used by the reader and isn’t intended to be called by a separate process
>>> card_lines = []'GRID,1,,1.0,2.0,3.0'] >>> card_name = 'GRID' >>> fields = to_fields(lines, card_name) >>> fields ['GRID', '1', '', '1.0', '2.0', '3.0']
write_path
Module¶
- Defines following useful methods:
- write_include
-
pyNastran.bdf.write_path.
_split_path
(abspath)[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=True)[source]¶ Writes a bdf INCLUDE file line given an imported filename.
Parameters: - filename – the filename to write
- is_windows – Windows has a special format for writing INCLUDE files so the format for a BDF that will run on Linux and Windows is different. We could check the platform, but since you might need to change platforms, it’s an option (default=True)
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