get_card Module

Inheritance diagram of pyNastran.bdf.bdf_interface.get_card
defines various methods to access high level BDF data:
  • GetCard() - get_card_ids_by_card_types(self, card_types=None, reset_type_to_slot_map=False,

    stop_on_missing_card=False, combine=False)

    • get_rslot_map(self, reset_type_to_slot_map=False)
    • get_cards_by_card_types(self, card_types, reset_type_to_slot_map=False,
      stop_on_missing_card=False)
    • get_SPCx_node_ids(self, spc_id, stop_on_failure=True)
    • get_SPCx_node_ids_c1( spc_id, stop_on_failure=True)
    • get_MPCx_node_ids( mpc_id, stop_on_failure=True)
    • get_MPCx_node_ids_c1( mpc_id, stop_on_failure=True)
    • get_load_arrays(self, subcase_id, nid_map, eid_map, node_ids, normals)
    • get_pressure_array(self, load_case, eids)
    • get_reduced_loads(self, load_id, scale=1., skip_scale_factor0=True, msg=’‘)
    • get_reduced_dloads(self, dload_id, scale=1., skip_scale_factor0=True, msg=’‘)
    • get_rigid_elements_with_node_ids(self, node_ids)
    • get_dependent_nid_to_components(self, mpc_id=None)
    • get_node_ids_with_elements(self, eids, msg=’‘)
    • get_elements_nodes_by_property_type(self, dtype=’int32’,
      save_element_types=False)
    • get_elements_properties_nodes_by_element_type(self, dtype=’int32’, solids=None)
    • get_element_ids_list_with_pids(self, pids=None)
    • get_pid_to_node_ids_and_elements_array(self, pids=None, etypes=None, idtype=’int32’)
    • get_element_ids_dict_with_pids(self, pids=None, stop_if_no_eids=True)
    • get_node_id_to_element_ids_map(self)
    • get_node_id_to_elements_map(self)
    • get_property_id_to_element_ids_map(self)
    • get_material_id_to_property_ids_map(self)
    • get_reduced_mpcs(self, mpc_id)
    • get_reduced_spcs(self, spc_id)
    • get_spcs(self, spc_id, consider_nodes=False)
    • get_mpcs(self, mpc_id)
class pyNastran.bdf.bdf_interface.get_card.GetCard[source]

Bases: pyNastran.bdf.bdf_interface.get_methods.GetMethods

defines various methods to access high level BDF data

get_MPCx_node_ids(self, mpc_id, consider_mpcadd=True, stop_on_failure=True)[source]

see pyNastran.bdf.mesh_utils.mpc_dependency.get_mpc_node_ids(...)

get_MPCx_node_ids_c1(self, mpc_id, consider_mpcadd=True, stop_on_failure=True)[source]

see pyNastran.bdf.mesh_utils.mpc_dependency.get_mpc_node_ids_c1(...)

get_SPCx_node_ids(self, spc_id, consider_spcadd=True, stop_on_failure=True)[source]

Get the SPC/SPCADD/SPC1/SPCAX IDs.

Parameters:
spc_id : int

the SPC id

stop_on_failure : bool; default=True

errors if parsing something new

Returns:
node_ids : List[int]

the constrained associated node ids

get_SPCx_node_ids_c1(self, spc_id, stop_on_failure=True)[source]

Get the SPC/SPCADD/SPC1/SPCAX IDs.

Parameters:
spc_id : int

the SPC id

stop_on_failure : bool; default=True

errors if parsing something new

Returns:
node_ids_c1 : Dict[component] = node_ids
component : str

the DOF to constrain

node_ids : List[int]

the constrained node ids

get_card_ids_by_card_types(self, card_types=None, reset_type_to_slot_map=False, stop_on_missing_card=False, combine=False)[source]
Parameters:
card_types : str / List[str] / default=None

the list of keys to consider (list of strings; string) None : all cards

reset_type_to_slot_map : bool

should the mapping dictionary be rebuilt (default=False); set to True if you added cards

stop_on_missing_card : bool

crashes if you request a card and it doesn’t exist

combine : bool; default=False

change out_dict into out_list combine the list of cards

Returns:
out_dict: dict[str]=List[ids]

the key=card_type, value=the ID of the card object

out_list: List[ids]

value=the ID of the card object useful

Examples

>>> out_dict = model.get_card_ids_by_card_types(
    card_types=['GRID', 'CTRIA3', 'CQUAD4'], combine=False)
>>> out_dict = {
    'GRID' : [1, 2, 10, 42, 1000],
    'CTRIA3' : [1, 2, 3, 5],
    'CQUAD4' : [4],
}

shell elements

>>> out_dict = model.get_card_ids_by_card_types(
    card_types=['CTRIA3', 'CQUAD4'], combine=True)
>>> out_dict = {
    [1, 2, 3, 4, 5],
}
get_cards_by_card_types(self, card_types, reset_type_to_slot_map=False, stop_on_missing_card=False)[source]
Parameters:
card_types : List[str]

the list of keys to consider

reset_type_to_slot_map : bool

should the mapping dictionary be rebuilt (default=False); set to True if you added cards

stop_on_missing_card : bool

crashes if you request a card and it doesn’t exist

Returns:
out_dict : dict[str] = List[BDFCard()]

the key=card_type, value=the card object

get_dependent_nid_to_components(self, mpc_id=None, stop_on_failure=True)[source]

see pyNastran.bdf.mesh_utils.mpc_dependency.get_dependent_nid_to_components(...)

get_element_ids_dict_with_pids(self, pids=None, stop_if_no_eids=True, msg='')[source]

Gets all the element IDs with a specific property ID.

Parameters:
pids : List[int] / int

list of property ID

stop_if_no_eids : bool; default=True

prevents crashing if there are no elements setting this to False really doesn’t make sense for non-DMIG models

Returns:
element_ids : dict[pid] = List[eid]

dictionary of lists by property pid : int

property id

eid : int

element id

For example, we want all the elements with pids=[4, 5, 6],
but we want them in separate groups

Notes

What happens with CONRODs?

get_element_ids_list_with_pids(self, pids=None)[source]

Gets all the element IDs with a specific property ID.

Parameters:
pids : List[int]; default=None -> all

list of property ID

Returns:
element_ids : List[int]

the element ids

For example, we want to get all the element ids with pids=[1, 2, 3]
get_element_nodes_by_element_type(self, dtype='int32', solids=None)[source]

see get_elements_properties_nodes_by_element_type

get_elements_nodes_by_property_type(self, dtype='int32', save_element_types=False)[source]

Gets a dictionary of (etype, pid) to [eids, node_ids]

Parameters:
dtype : str; default=’int32’

the type of the integers

save_element_types : bool; default=False

adds the etype_to_eids_pids_nids output

Returns:
etype_pid_to_eids_nids : dict[(etype, pid)]
etype : str

the element type

pid : int

the property id CONRODS have a pid of 0

eids : (neids, ) int ndarray

the elements with the property id of pid

nids : (neids, nnodes/element) int ndarray

the nodes corresponding to the element

etype_to_eids_pids_nids : dict[etype]

Enabled by save_element_types; default=None etype : str

the element type

eids : (neids, ) int ndarray

the elements with the property id of pid

pids : (neids, ) int ndarray

the property ids CONRODS have a pid of 0

nids : (neids, nnodes/element) int ndarray

the nodes corresponding to the element

get_elements_properties_nodes_by_element_type(self, dtype='int32', solids=None, stop_if_no_eids=True)[source]

Gets a dictionary of element type to [eids, pids, node_ids]

Parameters:
dtype : str; default=’int32’

the type of the integers

solids : dict[etype]
etype : str

the element type should only be CTETRA, CHEXA, CPENTA, CPYRAM

value : varies
(nnodes_min, nnodes_max) : Tuple(int, int)

the min/max number of nodes for the element

(nnodes, ) : Tuple(int, )

the number of nodes useful if you only have CTETRA4s or only want CTETRA10s fails if you’re wrong (and too low)

Returns:
etype_to_eids_pids_nids : dict[etype]
etype : str

the element type

eids : (neids, ) int ndarray

the elements with the property id of pid

pids : (neids, ) int ndarray

the property ids CONRODS have a pid of 0

nids : (neids, nnodes/element) int ndarray

the nodes corresponding to the element

get_load_arrays(self, subcase_id, eid_map, node_ids, normals, nid_map=None)[source]

see pyNastran.bdf.mesh_utils.forces_moments.get_load_arrays(...)

get_material_id_to_property_ids_map(self, msg='')[source]

Returns a dictionary that maps a material ID to a list of properties

Returns:
mid_to_pids_map : dict[int] = int

the mapping

msg : str; default=’‘

a message added to the error message

get_mklist(self)[source]

gets the MKLIST vector from MKAERO1/MKAERO2

get_mpcs(self, mpc_id, consider_mpcadd=True, stop_on_failure=True)[source]

see pyNastran.bdf.mesh_utils.mpc_dependency.get_mpcs(...)

get_nid_map(self, sort_ids=True)[source]

Maps the GRID/SPOINT/EPOINT ids to a sorted/unsorted order.

Parameters:
sort_ids : bool; default=True

sort the ids

Returns:
nid_map : Dict[nid]
nid : int

the GRID/SPOINT/EPOINT id

i : int

the index

..note :: GRIDs, SPOINTs, & EPOINTs are stored in separate slots,

so they are unorganized.

get_node_id_to_element_ids_map(self)[source]

Returns a dictionary that maps node IDs to a list of elemnent IDs

Todo

support 0d or 1d elements

Todo

support elements with missing nodes (e.g. CQUAD8 with missing nodes)

get_node_id_to_elements_map(self)[source]

Returns a dictionary that maps node IDs to a list of elements.

Returns:
nid_to_elements_map : Dict[nid]=List[eid]

node id to a list of elements

Todo

support 0d or 1d elements ..

Todo

support elements with missing nodes (e.g. CQUAD8 with missing nodes)

get_node_ids_with_elements(self, eids, msg='')[source]

Get the node IDs associated with a list of element IDs

Parameters:
eids : List[int]

list of element ID

msg : str

An additional message to print out if an element is not found

Returns:
node_ids : Set[int]

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_pid_to_node_ids_and_elements_array(self, pids=None, etypes=None, idtype='int32', msg='')[source]

a work in progress

Parameters:
pids : List[int]

list of property ID

etypes : List[str]

element types to consider

Returns:
pid_to_eids_ieids_map : dict[(pid, etype)] = eid_ieid
eid_ieid : (Nelements, 2) int ndarray

eid is the element id ieid is the index in the node_ids array

node_ids : (nelements, nnodes) int ndarray
nelements : int

the number of elements in the property type

nnodes : int

varies based on the element type

get_pressure_array(self, load_case_id, eids, stop_on_failure=True)[source]

see pyNastran.bdf.mesh_utils.forces_moments.get_pressure_array(...)

get_property_id_to_element_ids_map(self, msg='')[source]

Returns a dictionary that maps a property ID to a list of elements.

Returns:
pid_to_eids_map : Dict[pid]=List[eid]

property id to a list of elements

msg : str; default=’‘

a message added to the error message

get_reduced_dloads(self, dload_id, scale=1.0, consider_dload_combinations=True, skip_scale_factor0=False, msg='')[source]

Accounts for scale factors.

Parameters:
dload_id : int

the desired DLOAD id

consider_dload_combinations : bool; default=True

look at the DLOAD card

scale : float; default=1.0

additional scale factor on top of the existing LOADs

skip_scale_factor0 : bool; default=False

Skip loads with scale factor=0.0. Nastran does not do this. Nastran will fail if referenced loads do not exist.

msg : str

debug message

Returns:
dloads : List[loads]

a series of dload objects

scale_factors : List[float]

the associated scale factors

Warning

assumes xref=True ..

get_reduced_loads(self, load_case_id, scale=1.0, consider_load_combinations=True, skip_scale_factor0=False, stop_on_failure=True, msg='')[source]

Accounts for scale factors.

Parameters:
load_case_id : int

the desired LOAD id

consider_load_combinations : bool; default=True

look at the LOAD card

scale : float; default=1.0

additional scale factor on top of the existing LOADs

skip_scale_factor0 : bool; default=False

Skip loads with scale factor=0.0. Nastran does not do this. Nastran will fail if referenced loads do not exist.

stop_on_failure : bool; default=True

errors if parsing something new

msg : str

debug message

Returns:
loads : List[loads]

a series of load objects

scale_factors : List[float]

the associated scale factors

is_grav : bool

is there a gravity card

Warning

assumes xref=True ..

get_reduced_mpcs(self, mpc_id, consider_mpcadd=False, stop_on_failure=True)[source]

Get all traced MPCs that are part of a set

Parameters:
mpc_id : int

the MPC id

consider_mpcadd : bool

MPCADDs should not be considered when referenced from an MPCADD from a case control, True should be used.

stop_on_failure : bool; default=True

errors if parsing something new

Returns:
mpcs : List[MPC]

the various MPCs

get_reduced_nsms(self, nsm_id, consider_nsmadd=True, stop_on_failure=True)[source]

Get all traced NSMs that are part of a set

Parameters:
nsm_id : int

the NSM id

consider_nsmadd : bool

NSMADDs should not be considered when referenced from an NSMADD from a case control, True should be used.

stop_on_failure : bool; default=True

errors if parsing something new

Returns:
mpcs : List[NSM]

the various NSMs

get_reduced_spcs(self, spc_id, consider_spcadd=True, stop_on_failure=True)[source]

Get all traced SPCs that are part of a set

Parameters:
spc_id : int

the SPC id

consider_spcadd : bool

SPCADDs should not be considered when referenced from an SPCADD from a case control, True should be used.

stop_on_failure : bool; default=True

errors if parsing something new

Returns:
spcs : List[SPC]

the various SPCs

get_rigid_elements_with_node_ids(self, node_ids)[source]

see pyNastran.bdf.mesh_utils.mpc_dependency.get_rigid_elements_with_node_ids(...)

get_rslot_map(self, reset_type_to_slot_map=False)[source]

gets the rslot_map

get_spcs(self, spc_id, consider_nodes=False, stop_on_failure=True)[source]

Gets the SPCs in a semi-usable form.

Parameters:
spc_id : int

the desired SPC ID

consider_nodes : bool; default=False

True : consider the GRID card PS field False: consider the GRID card PS field

Returns:
nids : List[int]

the constrained nodes

comps : List[str]

the components that are constrained on each node

Considers:
  • SPC
  • SPC1
  • SPCADD
  • GRID
Doesn’t consider:
  • non-zero enforced value on SPC
  • GMSPC
nid_map

Gets the GRID/SPOINT/EPOINT ids to a sorted order.

Parameters:
sort_ids : bool; default=True

sort the ids

Returns:
nid_map : Dict[nid]
nid : int

the GRID/SPOINT/EPOINT id

i : int

the index

..note :: GRIDs, SPOINTs, & EPOINTs are stored in separate slots,

so they are unorganized.

..note :: see self.get_nid_map(sort_ids=False) for the unsorted version
reset_rslot_map(self)[source]

helper method for get_rslot_map