def __init__(self, seid, nodes_seid, nodes0, comment=''): """ Creates an SELOC card, which transforms the superelement SEID from PA to PB. Basically, define two CORD1Rs. Parameters ---------- seid : int the superelement to transform nodes_seid : List[int, int, int] the nodes in the superelement than define the resulting coordinate system nodes0 : List[int, int, int] the nodes in the superelement than define the starting coordinate system comment : str; default='' a comment for the card """ BaseCard.__init__(self) if comment: self.comment = comment self.seid = seid #: Identifiers of grids points. (Integer > 0) self.nodes_0 = expand_thru(nodes0, set_fields=False, sort_fields=False) self.nodes_seid = expand_thru(nodes_seid, set_fields=False, sort_fields=False) self.nodes_0_ref = None self.nodes_seid_ref = None
def __init__(self, sid, ids, is_skin=False, comment=''): """ Creates a SET1 card, which defines a list of structural grid points or element identification numbers. Parameters ---------- sid : int set id ids : List[int, str] AECOMP, SPLINEx, PANEL : all grid points must exist XYOUTPUT : missing grid points are ignored The only valid string is THRU ``ids = [1, 3, 5, THRU, 10]`` is_skin : bool; default=False if is_skin is used; ids must be empty """ Set.__init__(self) if comment: self.comment = comment #: Unique identification number. (Integer > 0) self.sid = sid #: List of structural grid point or element identification numbers. #: (Integer > 0 or 'THRU'; for the 'THRU' option, ID1 < ID2 or 'SKIN'; #: in field 3) self.ids = expand_thru(ids) self.clean_ids() self.is_skin = is_skin self.xref_type = None self.ids_ref = None
def add_card(cls, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) points = set(expand_thru(fields)) return cls(points, comment=comment)
def __init__(self, conid, sets, comment=''): ConstraintAdd.__init__(self) if comment: self.comment = comment self.conid = conid self.sets = expand_thru(sets) self.sets.sort()
def add_card(self, card, comment=''): assert self.n > 0, self.n i = self.i load_id = integer(card, 1, 'load_id') tbar = double(card, 3, 'Tbar') tprime = double(card, 4, 'Tprime') t1 = double_or_blank(card, 5, 'T1') t2 = double_or_blank(card, 6, 'T2') self.load_id[i] = load_id self.element_id[i] = integer(card, 2, 'element_id') self.tbar[i] = tbar self.tprime[i] = tprime self.temp[i, 0] = t1 self.temp[i, 1] = t2 self.i += 1 if len(card) >= 7: # i must be < self.n eids = expand_thru(card[9:]) for eid in eids: self.load_id[i] = load_id assert isinstance(eid, int), eid self.element_id[i] = eid self.tbar[i] = tbar self.tprime[i] = tprime self.temp[i, 0] = t1 self.temp[i, 1] = t2 self.i += 1 assert self.i <= self.n assert len(card) <= 7, '%s; n=%s' % (card, len(card)) #assert len(card) <= 7, len(card) self.eids = None
def __init__(self, ids, components, comment=''): Set.__init__(self) if comment: self.comment = comment #: Identifiers of grids points. (Integer > 0) self.ids = expand_thru(ids) self.components = components
def __init__(self, conid, sets, comment=''): ConstraintADD.__init__(self) if comment: self.comment = comment self.conid = conid self.sets = expand_thru(sets) self.sets.sort()
def __init__(self, sid, sets, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.sid = sid self.sets = expand_thru(sets) self.sets.sort()
def __init__(self, conid, components, nodes, comment=''): """ Creates an SPC1 card, which defines the degree of freedoms to be constrained to a value of 0.0 Parameters ---------- conid : int constraint id components : str the degree of freedoms to constrain (e.g., '1', '123') nodes : List[int] GRID/SPOINT ids """ Constraint.__init__(self) if comment: self.comment = comment if isinstance(nodes, integer_types): nodes = [nodes] if isinstance(components, int): components = str(components) self.conid = conid self.components = components self.nodes = expand_thru(nodes) self.nodes.sort() self.nodes_ref = None
def __init__(self, ids, comment=''): #Node.__init__(self) if comment: self.comment = comment if isinstance(ids, integer_types): ids = [ids] self.points = set(expand_thru(ids))
def __init__(self, components, nodes, comment=''): Constraint.__init__(self) if comment: self.comment = comment self.components = components self.nodes = expand_thru(nodes) self.nodes.sort()
def __init__(self, conid, constraints, nodes, comment=''): Constraint.__init__(self) if comment: self.comment = comment self.conid = conid self.constraints = constraints self.nodes = expand_thru(nodes) self.nodes.sort()
def get_spcadd_constraint(card): constraint_id = integer(card, 1, 'constraint_id') node_ids = card.fields(2) node_ids = expand_thru(node_ids) assert isinstance(constraint_id, int), constraint_id return constraint_id, node_ids
def __init__(self, seid, superelements, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.seid = seid #: Identifiers of grids points. (Integer > 0) self.superelements = expand_thru(superelements) self.superelements_ref = None
def __init__(self, side, coord, nids, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.side = side self.coord = coord self.nids = expand_thru(nids) assert coord in ['T1', 'T2', 'T3', 'R', 'C', 'S'], coord
def get_spc1_constraint(card): constraint_id = integer(card, 1, 'constraint_id') dofs = components(card, 2, 'constraints') # 246 = y; dx, dz dir node_ids = card.fields(3) node_ids = expand_thru(node_ids) assert isinstance(constraint_id, int), constraint_id return constraint_id, dofs, node_ids
def get_spc1_constraint(card): constraint_id = integer(card, 1, 'constraint_id') dofs = parse_components(card, 2, 'constraints') # 246 = y; dx, dz dir node_ids = card.fields(3) node_ids = expand_thru(node_ids) assert isinstance(constraint_id, int), constraint_id return constraint_id, dofs, node_ids
def __init__(self, seid, ids, comment=''): SetSuper.__init__(self) if comment: self.comment = comment self.seid = seid #: Grid or scalar point identification number. #: (0 < Integer < 1000000; G1 < G2) self.ids = expand_thru(ids) self.clean_ids()
def __init__(self, seid, comp, nids, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.seid = seid self.comp = comp #: Identifiers of grids points. (Integer > 0) self.nids = expand_thru(nids) self.nids_ref = None
def __init__(self, seid_a, seid_b, ids, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.seid_a = seid_a self.seid_b = seid_b #: Identifiers of grids points. (Integer > 0) self.ids = expand_thru(ids) self.ids_ref = None
def __init__(self, seid, psid, nodes, comment=''): BaseCard.__init__(self) if comment: self.comment = comment self.seid = seid self.psid = psid #: Identifiers of grids points. (Integer > 0) self.nodes = expand_thru(nodes) self.nodes_ref = None
def __init__(self, conid, components, nodes, comment=''): Constraint.__init__(self) if comment: self.comment = comment if isinstance(nodes, integer_types): nodes = [nodes] self.conid = conid self.components = components self.nodes = expand_thru(nodes) self.nodes.sort()
def test_expand_thru(self): """tests expand_thru""" values = expand_thru(['1', 'THRU', '10']) assert values == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], values values = expand_thru(['1', 'thru', '10']) assert values == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], values values = expand_thru([1, 2, 3, 4, 5]) assert values == [1, 2, 3, 4, 5], values values = expand_thru_by(['1', 'THRU', '10', 'BY', 2]) assert values == [1, 3, 5, 7, 9, 10], values values = expand_thru_by(['1', 'thru', '10', 'by', 2]) assert values == [1, 3, 5, 7, 9, 10], values values = expand_thru_by([1, 2, 3, 4, 5]) assert values == [1, 2, 3, 4, 5], values
def __init__(self, components, ids, comment=''): Set.__init__(self) if comment: self.comment = comment #: Component number. (Integer zero or blank for scalar points or any #: unique combination of the Integers 1 through 6 for grid points with #: no embedded blanks.) self.components = components #: Identifiers of grids points. (Integer > 0) self.ids = expand_thru(ids)
def __init__(self, sid, qflux, eids, comment=''): ThermalLoad.__init__(self) if comment: self.comment = comment #: Load set identification number. (Integer > 0) self.sid = sid #: Heat flux into element (FLOAT) self.qflux = qflux #: CHBDYj element identification numbers (Integer) #: .. todo:: use expand_thru_by ??? assert len(eids) > 0 self.eids = expand_thru(eids)
def add(self, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) ex = expand_thru(fields) ex = set(ex) self.spoint.update(ex) self._comments.append(comment) self.n = len(self.spoint)
def add_card(self, card, comment=''): fields = [] for i in range(1, len(card)): field = integer_or_string(card, i, 'ID%i' % i) fields.append(field) ex = expand_thru(fields) ex = set(ex) self.spoint.update(ex) self._comments.append(comment) self.n = len(self.spoint)
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment self.seid = integer(card, 1, 'seid') #: Grid or scalar point identification number. #: (0 < Integer < 1000000; G1 < G2) self.IDs = [] IDs = fields(integer_or_string, card, 'ID', i=2, j=len(card)) self.IDs = expand_thru(IDs) self.clean_ids()
def __init__(self, sid, qFlux, eids, comment=''): ThermalLoad.__init__(self) if comment: self.comment = comment #: Load set identification number. (Integer > 0) self.sid = sid #: Heat flux into element (FLOAT) self.qFlux = qFlux #: CHBDYj element identification numbers (Integer) #: .. todo:: use expand_thru_by ??? assert len(eids) > 0 self.eids = expand_thru(eids)
def add_card(self, card, comment=None): i = self.i self._comments.append(comment) #element_ids = {} #for i in range(ncards): #element_ids[i] = [] self.load_id[i] = integer(card, 1, 'load_id') eid = integer(card, 2, 'element_id') self.element_ids[i] = eid p1 = double_or_blank(card, 3, 'p1', 0.0) p = [ p1, double_or_blank(card, 4, 'p2', p1), double_or_blank(card, 5, 'p3', p1), double_or_blank(card, 6, 'p4', p1) ] self.pressures[i, :] = p self.element_ids[i] = [eid] if (integer_string_or_blank(card, 7, 'g1/THRU') == 'THRU' and integer_or_blank(card, 8, 'eid2')): # plates eid2 = integer(card, 8, 'eid2') if eid2: self.element_ids[i] = list( unique( expand_thru([eid, 'THRU', eid2], set_fields=False, sort_fields=False))) #self.g1 = None #self.g34 = None else: #: used for CPENTA, CHEXA self.element_ids[i] = [eid] #: used for solid element only self.g1[i] = integer_or_blank(card, 7, 'g1', -1) #: g3/g4 - different depending on CHEXA/CPENTA or CTETRA self.g34[i] = integer_or_blank(card, 8, 'g34', -1) #: Coordinate system identification number. See Remark 2. #: (Integer >= 0;Default=0) self.cid[i] = integer_or_blank(card, 9, 'cid', 0) self.nvector[i, :] = [ double_or_blank(card, 10, 'N1'), double_or_blank(card, 11, 'N2'), double_or_blank(card, 12, 'N3'), ] self.sorl[i] = string_or_blank(card, 13, 'sorl', 'SURF') self.ldir[i] = string_or_blank(card, 14, 'ldir', 'NORM') assert len(card) <= 15, 'len(PLOAD4 card) = %i\ncard=%s' % (len(card), card) self.i += 1
def __init__(self, ssid, psid, ids, comment=''): SetSuper.__init__(self) if comment: self.comment = comment #: Identification number for secondary superelement. (Integer >= 0). self.ssid = ssid #: Identification number for the primary superelement. (Integer >= 0). self.psid = psid #: Exterior grid point identification numbers for the primary #: superelement. (Integer > 0) self.ids = expand_thru(ids) self.clean_ids()
def add_card(cls, card, comment=''): seid = integer(card, 1, 'seid') components = fcomponents_or_blank(card, 2, 'components', 0) nfields = len(card) ids = [] i = 1 for ifield in range(3, nfields): idi = integer_string_or_blank(card, ifield, 'ID%i' % i) if idi: i += 1 ids.append(idi) ids = expand_thru(ids) return cls(seid, components, ids, comment=comment)
def __init__(self, sid, ids, is_skin=False, comment=''): Set.__init__(self) if comment: self.comment = comment #: Unique identification number. (Integer > 0) self.sid = sid #: List of structural grid point or element identification numbers. #: (Integer > 0 or 'THRU'; for the 'THRU' option, ID1 < ID2 or 'SKIN'; #: in field 3) self.ids = expand_thru(ids) self.clean_ids() self.is_skin = is_skin self.xref_type = None
def __init__(self, card=None, data=None, comment=''): SetSuper.__init__(self, card, data) if comment: self._comment = comment #: Identification number for secondary superelement. (Integer >= 0). self.ssid = integer(card, 1, 'ssid') #: Identification number for the primary superelement. (Integer >= 0). self.psid = integer(card, 2, 'psid') #: Exterior grid point identification numbers for the primary #: superelement. (Integer > 0) self.IDs = [] IDs = fields(integer_or_string, card, i=3, j=len(card)) self.IDs = expand_thru(IDs) self.clean_ids()
def __init__(self, sid, desc, ids, comment=''): Set.__init__(self) if comment: self.comment = comment #: Unique identification number. (Integer > 0) self.sid = sid #: Set description (Character). Valid options are 'GRID', 'ELEM', #: 'POINT' and 'PROP'. if desc == 'ELEM': desc = 'ELEMENT' self.desc = desc #: Identifiers of grids points, elements, points or properties. #: (Integer > 0) self.ids = expand_thru(ids) self.xref_type = None
def add_card(self, card, comment=None): i = self.i self._comments.append(comment) #element_ids = {} #for i in range(ncards): #element_ids[i] = [] self.load_id[i] = integer(card, 1, 'load_id') eid = integer(card, 2, 'element_id') self.element_ids[i] = eid p1 = double_or_blank(card, 3, 'p1', 0.0) p = [p1, double_or_blank(card, 4, 'p2', p1), double_or_blank(card, 5, 'p3', p1), double_or_blank(card, 6, 'p4', p1)] self.pressures[i, :] = p self.element_ids[i] = [eid] if(integer_string_or_blank(card, 7, 'g1/THRU') == 'THRU' and integer_or_blank(card, 8, 'eid2')): # plates eid2 = integer(card, 8, 'eid2') if eid2: self.element_ids[i] = list(unique(expand_thru([eid, 'THRU', eid2], set_fields=False, sort_fields=False))) #self.g1 = None #self.g34 = None else: #: used for CPENTA, CHEXA self.element_ids[i] = [eid] #: used for solid element only self.g1[i] = integer_or_blank(card, 7, 'g1', -1) #: g3/g4 - different depending on CHEXA/CPENTA or CTETRA self.g34[i] = integer_or_blank(card, 8, 'g34', -1) #: Coordinate system identification number. See Remark 2. #: (Integer >= 0;Default=0) self.cid[i] = integer_or_blank(card, 9, 'cid', 0) self.nvector[i, :] = [ double_or_blank(card, 10, 'N1'), double_or_blank(card, 11, 'N2'), double_or_blank(card, 12, 'N3'), ] self.sorl[i] = string_or_blank(card, 13, 'sorl', 'SURF') self.ldir[i] = string_or_blank(card, 14, 'ldir', 'NORM') assert len(card) <= 15, 'len(PLOAD4 card) = %i\ncard=%s' % (len(card), card) self.i += 1
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment #: Identifiers of grids points. (Integer > 0) self.IDs = [] if string_or_blank(card, 2, 'C') == 'ALL': self.components = '123456' else: self.components = components(card, 1, 'components') IDs2 = [] ii = 1 for ifield in range(2, len(card)): integer_or_string(card, ifield, 'ID' % ii) ii += 1 self.IDs = expand_thru(IDs2)
def __init__(self, ids, components, comment=''): """ Creates an CSET1 card, which defines the degree of freedoms that will be free during a generalized dynamic reduction or component model synthesis calculation. Parameters ---------- components : str the degree of freedoms to be retained (e.g., '1', '123') ids : List[int] the GRID/SPOINT ids """ Set.__init__(self) if comment: self.comment = comment #: Identifiers of grids points. (Integer > 0) self.ids = expand_thru(ids) self.components = components
def __init__(self, sid, sets, comment=''): """ Creates an NSMADD card, which sum NSM sets Parameters ---------- sid : int the NSM Case Control value sets : List[int] the NSM, NSM1, NSML, NSML1 values comment : str; default='' a comment for the card """ BaseCard.__init__(self) if comment: self.comment = comment self.sid = sid self.sets = expand_thru(sets) self.sets.sort()
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment #: Unique identification number. (Integer > 0) self.sid = integer(card, 1, 'sid') #: Set description (Character). Valid options are 'GRID', 'ELEM', #: 'POINT' and 'PROP'. self.desc = string(card, 2, 'desc') if self.desc == 'ELEM': self.desc = 'ELEMENT' assert self.desc in ['GRID', 'POINT', 'ELEMENT', 'PROP'], 'desc = %r' % self.desc #: Identifiers of grids points, elements, points or properties. #: (Integer > 0) self.IDs = [] IDs = fields(integer_or_string, card, 'ID', i=3, j=len(card)) self.IDs = expand_thru(IDs) self.clean_ids()
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment #: Component number. (Integer zero or blank for scalar points or any #: unique combination of the Integers 1 through 6 for grid points with #: no embedded blanks.) self.components = components_or_blank(card, 1, 'components', 0) nfields = len(card) IDs = [] i = 1 for ifield in range(2, nfields): ID = integer_string_or_blank(card, ifield, 'ID%i' % i) if ID: i += 1 IDs.append(ID) #: Identifiers of grids points. (Integer > 0) self.IDs = expand_thru(IDs)
def __init__(self, card=None, data=None, comment=''): Set.__init__(self, card, data) if comment: self._comment = comment #: Unique identification number. (Integer > 0) self.sid = integer(card, 1, 'sid') self.IDs = [] IDs = fields(integer_or_string, card, 'ID', i=2, j=len(card)) self.is_skin = False i = 0 if isinstance(IDs[0], string_types) and IDs[0] == 'SKIN': self.is_skin = True i += 1 #: List of structural grid point or element identification numbers. #: (Integer > 0 or 'THRU'; for the 'THRU' option, ID1 < ID2 or 'SKIN'; #: in field 3) self.IDs = expand_thru(IDs[i:]) self.clean_ids() self.xref_type = None
def add_op2_data(cls, data, comment=''): fields = data assert isinstance(data, list), data assert isinstance(data[0], int), data points = set(expand_thru(fields)) return cls(points, comment=comment)
def build(self): cards = self._cards ncards = len(cards) self.n = ncards if ncards: float_fmt = self.model.float self.load_id = zeros(ncards, 'int32') #: Element ID self.element_id = zeros(ncards, 'int32') #: Property ID self.pressures = zeros((ncards, 4), 'int32') element_ids = {} for i in range(ncards): element_ids[i] = [] self.g1 = full(ncards, nan, 'int32') self.g34 = full(ncards, nan, 'int32') self.ldir = full(ncards, nan, '|S4') self.sorl = full(ncards, nan, '|S4') self.cid = zeros(ncards, dtype='int32') self.NVector = zeros((ncards, 3), dtype=float_fmt) for i, card in enumerate(cards): self.load_id[i] = integer(card, 1, 'load_id') eid = integer(card, 2, 'element_id') self.element_id[i] = eid p1 = double_or_blank(card, 3, 'p1', 0.0) p = [p1, double_or_blank(card, 4, 'p2', p1), double_or_blank(card, 5, 'p3', p1), double_or_blank(card, 6, 'p4', p1)] self.pressures[i, :] = p self.element_ids[i] = [eid] if(integer_string_or_blank(card, 7, 'g1/THRU') == 'THRU' and integer_or_blank(card, 8, 'eid2')): # plates eid2 = integer(card, 8, 'eid2') if eid2: self.element_ids[i] = list(unique(expand_thru([self.eid, 'THRU', eid2], set_fields=False, sort_fields=False))) #self.g1 = None #self.g34 = None else: #: used for CPENTA, CHEXA self.element_ids[i] = [self.eid] #: used for solid element only self.g1[i] = integer_or_blank(card, 7, 'g1') #: g3/g4 - different depending on CHEXA/CPENTA or CTETRA self.g34[i] = integer_or_blank(card, 8, 'g34') #: Coordinate system identification number. See Remark 2. #: (Integer >= 0;Default=0) self.cid[i] = integer_or_blank(card, 9, 'cid', 0) self.NVector[i, :] = [ double_or_blank(card, 10, 'N1', 0.0), double_or_blank(card, 11, 'N2', 0.0), double_or_blank(card, 12, 'N3', 0.0), ] self.sorl[i] = string_or_blank(card, 13, 'sorl', 'SURF') self.ldir[i] = string_or_blank(card, 14, 'ldir', 'NORM') assert len(card) <= 15, 'len(PLOAD4 card) = %i\ncard=%s' % (len(card), card) i = self.load_id.argsort() #self.element_id = self.element_id[i] self.pressures = self.pressures[i, :] #self.node_ids = self.node_ids[i, :] #element_ids = {} #for j in range(ncards): #element_ids[j] = element_ids[i[j]] self.g1 = self.g1[i] self.g34 = self.g34[i] self.ldir = self.ldir[i] self.sorl = self.sorl[i] self.cid = self.cid[i] self.NVector = self.NVector[i, :] self.n += len(eids) self.load_cases = {} self.load_ids = unique(self.load_id) else: self.load_id = array([], dtype='int32')