bdfInterface Package¶
addCard Module¶
- class pyNastran.bdf.bdfInterface.addCard.AddMethods[source]¶
Bases: object
- add_creep_material(material, allowOverwrites=False)[source]¶
Note
May be removed in the future. Are CREEP cards materials? They have an MID, but reference structural materials.
assign_type Module¶
- pyNastran.bdf.bdfInterface.assign_type._get_dtype(value)[source]¶
Get the type of the input value in a form that is clear.
Parameters: value – the value to get the type of
- pyNastran.bdf.bdfInterface.assign_type.blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.components(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.components_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.double(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.double_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.double_or_string(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.double_string_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
Returns value: a double, string, or default value
Raises SyntaxError: if there is an invalid type
- pyNastran.bdf.bdfInterface.assign_type.field(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.fields(f, card, fieldname, i, j=None)[source]¶
Todo
improve fieldname
- pyNastran.bdf.bdfInterface.assign_type.integer(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.integer_double_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.integer_double_or_string(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- pyNastran.bdf.bdfInterface.assign_type.integer_double_string_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.integer_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.integer_or_double(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
Returns value: the value with the proper type
Raises SyntaxError: if there’s an invalid type
- pyNastran.bdf.bdfInterface.assign_type.integer_or_string(card, ifield, fieldname)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.integer_string_or_blank(card, ifield, fieldname, default=None)[source]¶
Parameters: - card – BDF card as a list
- ifield – field number
- fieldname – name of field
- default – the default value for the field (default=None)
- pyNastran.bdf.bdfInterface.assign_type.interpret_value(value_raw, card='')[source]¶
Converts a value from nastran format into python format.
BDF_Card Module¶
- class pyNastran.bdf.bdfInterface.BDF_Card.BDFCard(card=None, debug=False)[source]¶
Bases: object
- field(i, default=None)[source]¶
Gets the ith field on the card
Parameters: - self – the object pointer
- i (integer) – the ith field on the card (following list notation)
- default – the default value for the field
Returns value: the value on the ith field
- fields(i=0, j=None, defaults=None)[source]¶
Gets multiple fields on the card
Parameters: - self – the object pointer
- i (integer >= 0) – the ith field on the card (following list notation)
- j (integer or None (default=end of card)) – the jth field on the card (None means till the end of the card)
- defaults – the default value for the field (as a list) len(defaults)=i-j-1
Returns value: the values on the ith-jth fields
bdf_writeMesh Module¶
- This file defines:
- WriteMesh
- class pyNastran.bdf.bdfInterface.bdf_writeMesh.WriteMesh[source]¶
Bases: object
- Major methods:
- model.write_bdf(...)
- model.echo_bdf(...)
- model.auto_reject_bdf(...)
- _output_helper(out_filename, interspersed, size, is_double)[source]¶
Performs type checking on the write_bdf inputs
- _write_aero_control(outfile, size=8, is_double=False)[source]¶
Writes the aero control surface cards
- _write_case_control_deck(outfile)[source]¶
Writes the Case Control Deck.
Parameters: self – the BDF object
- _write_common(outfile, size=8, is_double=False)[source]¶
Write the common outputs so none get missed...
Parameters: self – the BDF object Returns msg: part of the bdf
- _write_constraints(outfile, size=8, is_double=False)[source]¶
Writes the constraint cards sorted by ID
- _write_coords(outfile, size=8, is_double=False)[source]¶
Writes the coordinate cards in a sorted order
- _write_dmigs(outfile, size=8, is_double=False)[source]¶
Writes the DMIG cards
Parameters: - self – the BDF object
- size – large field (16) or small field (8)
Returns msg: string representation of the DMIGs
- _write_elements(outfile, size=8, is_double=False)[source]¶
Writes the elements in a sorted order
Parameters: self – the BDF object
- _write_elements_properties(outfile, size=8, is_double=False)[source]¶
Writes the elements and properties in and interspersed order
- _write_executive_control_deck(outfile)[source]¶
Writes the executive control deck.
Parameters: self – the BDF object
- _write_header(outfile)[source]¶
Writes the executive and case control decks.
Parameters: self – the BDF object
- _write_nodes(outfile, size=8, is_double=False)[source]¶
Writes the NODE-type cards
Parameters: self – the BDF object
- _write_optimization(outfile, size=8, is_double=False)[source]¶
Writes the optimization cards sorted by ID
- _write_params(outfile, size=8, is_double=False)[source]¶
Writes the PARAM cards
Parameters: self – the BDF object
- _write_properties(outfile, size=8, is_double=False)[source]¶
Writes the properties in a sorted order
- _write_rejects(outfile, size=8, is_double=False)[source]¶
Writes the rejected (processed) cards and the rejected unprocessed cardLines
- _write_rigid_elements(outfile, size=8, is_double=False)[source]¶
Writes the rigid elements in a sorted order
- _write_thermal_materials(outfile, size=8, is_double=False)[source]¶
Writes the thermal materials in a sorted order
- auto_reject_bdf(infile_name)[source]¶
This method parses supported cards, but does not group them into nodes, elements, properties, etc.
Todo
maybe add the write method
- echo_bdf(infile_name)[source]¶
This method removes all comment lines from the bdf A write method is stil required.
Todo
maybe add the write method
- write_bdf(out_filename=None, size=8, is_double=False, interspersed=True, enddata=None)[source]¶
Writes the BDF.
Parameters: - self – the BDF object
- out_filename – the name to call the output bdf (default=None; pops a dialog)
- size – the field size (8 is recommended)
- is_double – small field (False) or large field (True); default=False
- interspersed – Writes a bdf with properties & elements interspersed like how Patran writes the bdf. This takes slightly longer than if interspersed=False, but makes it much easier to compare to a Patran-formatted bdf and is more clear. (default=True)
- enddata – Flag to enable/disable writing ENDDATA (default=None -> depends on input BDF)
crossReference Module¶
Links up the various cards in the BDF.
For example, with cross referencing...
>>> model = BDF()
>>> model.read_bdf(bdf_filename, xref=True)
>>> nid1 = 1
>>> node1 = model.nodes[nid1]
>>> node.nid
1
>>> node.xyz
[1., 2., 3.]
>>> node.Cid()
3
>>> node.cid
CORD2S, 3, 1, 0., 0., 0., 0., 0., 1.,
1., 0., 0.
# get the position in the global frame
>>> node.Position()
[4., 5., 6.]
# get the position with respect to another frame
>>> node.PositionWRT(model, cid=2)
[4., 5., 6.]
Without cross referencing...
>>> model = BDF()
>>> model.read_bdf(bdf_filename, xref=True)
>>> nid1 = 1
>>> node1 = model.nodes[nid1]
>>> node.nid
1
>>> node.xyz
[1., 2., 3.]
>>> node.Cid()
3
>>> node.cid
3
# get the position in the global frame
>>> node.Position()
Error!
Cross-referencing allows you to easily jump across cards and also helps with calculating things like position, area, and mass. The BDF is designed around the idea of cross-referencing, so it’s recommended that you use it.
- class pyNastran.bdf.bdfInterface.crossReference.XrefMesh[source]¶
Bases: object
Links up the various cards in the BDF.
The main BDF class defines all the parameters that are used.
- _cross_reference_coordinates()[source]¶
Links up all the coordinate cards to other coordinate cards and nodes
- _cross_reference_elements()[source]¶
Links the elements to nodes, properties (and materials depending on the card).
- _cross_reference_masses()[source]¶
Links the mass to nodes, properties (and materials depending on the card).
- _cross_reference_materials()[source]¶
Links the materials to materials (e.g. MAT1, CREEP) often this is a pass statement
- cross_reference(xref=True, xref_elements=True, xref_properties=True, xref_materials=True, xref_loads=True, xref_constraints=True, xref_aero=True)[source]¶
Links up all the cards to the cards they reference
Parameters: - xref – cross references the model (default=True)
- xref_element – set cross referencing of elements (default=True)
- xref_properties – set cross referencing of properties (default=True)
- xref_materials – set cross referencing of materials (default=True)
- xref_loads – set cross referencing of loads (default=True)
- xref_constraints – set cross referencing of constraints (default=True)
- xref_aero – set cross referencing of CAERO/SPLINEs (default=True)
To only cross-reference nodes:
model = BDF() model.read_bdf(bdf_filename, xref=False) model.cross_reference(xref=True, xref_loads=False, xref_constraints=False, xref_materials=False, xref_properties=False, xref_aero=False, xref_masses=False)
Warning
be careful if you call this method
getCard Module¶
- class pyNastran.bdf.bdfInterface.getCard.GetMethods[source]¶
Bases: pyNastran.bdf.deprecated.GetMethodsDeprecated
- Nodes(nids, allowEmptyNodes=False, msg=u'')[source]¶
Returns a series of node objects given a list of node IDs
- _GetMethods__test_method()¶
- get_element_ids_dict_with_pids(pids)[source]¶
Gets all the element IDs with a specific property ID.
Parameters: - self – the BDF object
- pids – list of property ID
Returns element_ids: as a dictionary of lists by property
For example, we want all the elements with pids=[4, 5, 6], but we want them in separate groups
model = BDF() model.read_bdf(bdf_filename) pids = [4, 5, 6] eids_dict = model.get_element_ids_with_pids(pids, mode='dict')
- get_element_ids_list_with_pids(pids)[source]¶
Gets all the element IDs with a specific property ID.
Parameters: - self – the BDF object
- pids – list of property ID
Returns element_ids: as a list
For example, we want to get all the element ids with pids=[1, 2, 3]
model = BDF() model.read_bdf(bdf_filename) pids = [1, 2, 3] eids_list = model.get_element_ids_with_pids(pids, mode='list')
- get_material_id_to_property_ids_map()[source]¶
Returns a dictionary that maps a material ID to a list of properties
Returns mid_to_pids_map: the mapping >>> mid_to_pid_map = get_material_id_to_property_ids_map() >>> mid = 1 >>> pids = get_material_id_to_property_ids_map[mid] >>> pids [1, 2, 3]
Note
all properties require an mid to be counted (except for PCOMP, which has multiple mids)
- get_node_id_to_element_ids_map()[source]¶
Returns a dictionary that maps a node ID to a list of elemnents
Todo
support 0d or 1d elements
Todo
support elements with missing nodes (e.g. CQUAD8 with missing nodes)
- get_node_ids_with_elements(eids, msg=u'')[source]¶
Get the node IDs associated with a list of element IDs
Parameters: - self – the BDF object
- eids – list of element ID
- msg – a additional message to print out if an element is not found
Returns node_ids: set of node IDs
For example
>>> eids = [1, 2, 3] # list of elements with pid=1 >>> msg = ' which are required for pid=1' >>> node_ids = bdf.get_node_ids_with_elements(eids, msg=msg)
- get_property_id_to_element_ids_map()[source]¶
Returns a dictionary that maps a property ID to a list of elemnents
- get_x_associated_with_y(xdict, xkeys, ykeys, stop_on_failure=True)[source]¶
Get the range of sub-properties of a card.
Note
Assumes you’re taking a single path through the cards. You could probably explicitly code these queries faster, but this method has a lot of flexibility with very little user code.
Parameters: - self – the BDF object
- xdict – the BDF attribute that should be querried (e.g. self.elements)
- xkeys – the list of object keys that should be stepped through associated with xdict (e.g. eids=[1, 2, 3])
- ykeys – the list of response keys that should be stepped through (e.g. [‘pid’, ‘mid’, ‘mid’])
- stop_on_failure – Should an error be raised if there is an invalid key? For example, get all material used by elements, but don’t crash on CONRODs.
Returns results: The set of all values used
# Get nodes associated with eid=[1, 2, 3] nodes = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['nodes']) # Get node IDs associated with eid=[1, 2, 3] nodesIDs = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['nodes', 'nid']) # Get coord IDs associated with eid=[1, 2, 3] coordIDs = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['nodes', 'cp', 'cid']) # Get properties associated with eid=[1, 2, 3] properties = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['pid']) # Get materials associated with eid=[1, 2, 3] materials = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['pid', 'mid']) # Get material IDs associated with eid=[1, 2, 3] materialIDs = self.get_x_associated_with_y( self.elements, [1, 2, 3], ['pid', 'mid', 'mid']) # Get the values for Young's Modulus E = self.get_x_associated_with_y( self.elements, None, ['pid', 'mid', 'e'])
- pyNastran.bdf.bdfInterface.getCard._getattr(out_set, xi, xkeys, nlevels_left=0, stop_on_failure=True)[source]¶
Recursive method to help get_x_associated_with_y get the value of xkeys for the given variable xi
Parameters: - out_set (SET) – the SET of all outputs that will be filled and implicitly returned
- xi (BDF BaseCard) – the current variable being iterated over
- xkeys (LIST of STRINGS) – the variables left to iterate over
- nlevels_left (INT >= 0) – the number of levels still to iterate over
- stop_on_failure (bool) – should the code crash if a certain xkey cannot be found