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_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_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)

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

creates the attributes for the BDF

_upcast_int_dtype(dtype: str) → str[source]

helper for 64-bit integers

get_MPCx_node_ids(mpc_id: int, consider_mpcadd: bool = True, stop_on_failure: bool = True) → List[List[int]][source]

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

get_MPCx_node_ids_c1(mpc_id: int, consider_mpcadd: bool = True, stop_on_failure: bool = True) → Tuple[Dict[str, List[int]], Dict[str, List[int]]][source]

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

get_SPCx_node_ids(spc_id: int, consider_spcadd: bool = True, stop_on_failure: bool = True) → List[int][source]

Get the SPC/SPCADD/SPC1/SPCAX IDs.

Parameters
spc_idint

the SPC id

stop_on_failurebool; default=True

errors if parsing something new

Returns
node_idsList[int]

the constrained associated node ids

get_SPCx_node_ids_c1(spc_id: int, stop_on_failure: bool = True) → Dict[str, List[int]][source]

Get the SPC/SPCADD/SPC1/SPCAX IDs.

Parameters
spc_idint

the SPC id

stop_on_failurebool; default=True

errors if parsing something new

Returns
node_ids_c1Dict[component] = node_ids
componentstr

the DOF to constrain

node_idsList[int]

the constrained node ids

get_card_ids_by_card_types(card_types: Optional[List[str]] = None, reset_type_to_slot_map: bool = False, stop_on_missing_card: bool = False, combine: bool = False) → Dict[str, List[int]][source]
Parameters
card_typesstr / List[str] / default=None

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

reset_type_to_slot_mapbool

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

stop_on_missing_cardbool

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

combinebool; 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(card_types: List[str], reset_type_to_slot_map: bool = False, stop_on_missing_card: bool = False) → None[source]
Parameters
card_typesList[str]

the list of keys to consider

reset_type_to_slot_mapbool

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

stop_on_missing_cardbool

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

Returns
out_dictdict[str] = List[BDFCard()]

the key=card_type, value=the card object

get_dependent_nid_to_components(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(pids: Union[List[int], int, None] = None, stop_if_no_eids: bool = True, msg: str = '') → Dict[int, List[int]][source]

Gets all the element IDs with a specific property ID.

Parameters
pidsList[int] / int

list of property ID

stop_if_no_eidsbool; default=True

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

Returns
element_idsdict[pid] = List[eid]

dictionary of lists by property pid : int

property id

eidint

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(pids: Optional[List[int]] = None) → List[int][source]

Gets all the element IDs with a specific property ID.

Parameters
pidsList[int]; default=None -> all

list of property ID

Returns
element_idsList[int]

the element ids

For example, we want to get all the element ids with pids=[1, 2, 3]
get_elements_nodes_by_property_type(dtype: str = 'int32', save_element_types: bool = False) → Tuple[Dict[Tuple[str, int], Tuple[List[int], List[int]]]][source]

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

Parameters
dtypestr; default=’int32’

the type of the integers

save_element_typesbool; default=False

adds the etype_to_eids_pids_nids output

Returns
etype_pid_to_eids_nidsdict[(etype, pid)]
etypestr

the element type

pidint

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_nidsdict[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(dtype: str = 'int32', solids: Optional[Dict[str, Any]] = None, stop_if_no_eids: bool = True) → numpy.array[source]

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

Parameters
dtypestr; default=’int32’

the type of the integers

solidsdict[etype]
etypestr

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

valuevaries
(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_nidsdict[etype]
etypestr

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_material_id_to_property_ids_map(msg: str = '') → Dict[int, List[int]][source]

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

Returns
mid_to_pids_mapdict[int] = int

the mapping

msgstr; default=’’

a message added to the error message

Note

all properties require an mid to be counted (except for PCOMP, which has multiple mids)

get_mklist() → numpy.ndarray[source]

gets the MKLIST vector from MKAERO1/MKAERO2

get_mpcs(mpc_id: int, consider_mpcadd: bool = True, stop_on_failure: bool = True) → Tuple[List[int], List[str]][source]

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

get_nid_map(sort_ids: bool = True) → Dict[int, int][source]

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

Parameters
sort_idsbool; default=True

sort the ids

Returns
nid_mapDict[nid]
nidint

the GRID/SPOINT/EPOINT id

iint

the index

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

so they are unorganized.

get_node_id_to_element_ids_map() → Dict[int, List[int]][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() → Dict[int, List[int]][source]

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

Returns
nid_to_elements_mapDict[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(eids: List[int], msg: str = '') → Set[int][source]

Get the node IDs associated with a list of element IDs

Parameters
eidsList[int]

list of element ID

msgstr

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

Returns
node_idsSet[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(pids: Union[List[int], int, None] = None, etypes: Optional[List[str]] = None, idtype: str = 'int32', msg: str = '') → Tuple[Dict[int, str], numpy.ndarray][source]

a work in progress

Parameters
pidsList[int]

list of property ID

etypesList[str]

element types to consider

Returns
pid_to_eids_ieids_mapdict[(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
nelementsint

the number of elements in the property type

nnodesint

varies based on the element type

get_property_id_to_element_ids_map(msg: str = '') → Dict[int, List[int]][source]

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

Returns
pid_to_eids_mapDict[pid]=List[eid]

property id to a list of elements

msgstr; default=’’

a message added to the error message

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

Accounts for scale factors.

Parameters
dload_idint

the desired DLOAD id

consider_dload_combinationsbool; default=True

look at the DLOAD card

scalefloat; default=1.0

additional scale factor on top of the existing LOADs

skip_scale_factor0bool; default=False

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

msgstr

debug message

Returns
dloadsList[loads]

a series of dload objects

scale_factorsList[float]

the associated scale factors

Warning

assumes xref=True ..

get_reduced_loads(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_idint

the desired LOAD id

consider_load_combinationsbool; default=True

look at the LOAD card

scalefloat; default=1.0

additional scale factor on top of the existing LOADs

skip_scale_factor0bool; 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_failurebool; default=True

errors if parsing something new

msgstr

debug message

Returns
loadsList[loads]

a series of load objects

scale_factorsList[float]

the associated scale factors

is_gravbool

is there a gravity card

Warning

assumes xref=True ..

get_reduced_mpcs(mpc_id: int, consider_mpcadd: bool = False, stop_on_failure: bool = True) → List[Any][source]

Get all traced MPCs that are part of a set

Parameters
mpc_idint

the MPC id

consider_mpcaddbool

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

stop_on_failurebool; default=True

errors if parsing something new

Returns
mpcsList[MPC]

the various MPCs

get_reduced_nsms(nsm_id: int, consider_nsmadd: bool = True, stop_on_failure: bool = True) → List[Any][source]

Get all traced NSMs that are part of a set

Parameters
nsm_idint

the NSM id

consider_nsmaddbool

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

stop_on_failurebool; default=True

errors if parsing something new

Returns
mpcsList[NSM]

the various NSMs

get_reduced_spcs(spc_id: int, consider_spcadd: bool = True, stop_on_failure: bool = True) → List[Any][source]

Get all traced SPCs that are part of a set

Parameters
spc_idint

the SPC id

consider_spcaddbool

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

stop_on_failurebool; default=True

errors if parsing something new

Returns
spcsList[SPC]

the various SPCs

get_rigid_elements_with_node_ids(node_ids)[source]

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

get_rslot_map(reset_type_to_slot_map=False) → Dict[str, str][source]

gets the rslot_map

get_spcs(spc_id: int, consider_nodes: bool = False, stop_on_failure: bool = True) → Tuple[List[int], List[str]][source]

Gets the SPCs in a semi-usable form.

Parameters
spc_idint

the desired SPC ID

consider_nodesbool; default=False

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

Returns
nidsList[int]

the constrained nodes

compsList[str]

the components that are constrained on each node

Considers:
  • SPC

  • SPC1

  • SPCADD

  • GRID

Doesn’t consider:
  • non-zero enforced value on SPC

  • GMSPC

property nid_map

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

Parameters
sort_idsbool; default=True

sort the ids

Returns
nid_mapDict[nid]
nidint

the GRID/SPOINT/EPOINT id

iint

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() → None[source]

helper method for get_rslot_map

pyNastran.bdf.bdf_interface.get_card._get_pid_to_node_ids_and_elements_array(model: BDF, pids: List[int], etypes: List[str], msg: str, idtype: str)[source]

a work in progress

Parameters
pidsList[int]

list of property ID

etypesList[str]

element types to consider

msgstr

???

idetypestr

‘int32’, ‘int64’

Returns
pid_to_eids_ieids_mapdict[(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
nelementsint

the number of elements in the property type

nnodesint

varies based on the element type