def add_card(self, card_lines, card_name, comment='', is_list=True): card_name = card_name.upper() self._increase_card_count(card_name) if card_name in ['DEQATN']: card_obj = card_lines card = card_lines else: if is_list: fields = card_lines else: fields = to_fields(card_lines, card_name) # apply OPENMDAO syntax if self._is_dynamic_syntax: fields = [self._parse_dynamic_syntax(field) if '%' in field[0:1] else field for field in fields] card = wipe_empty_fields([interpret_value(field, fields) if field is not None else None for field in fields]) else: # leave everything as strings card = wipe_empty_fields(fields) card_obj = BDFCard(card) if card_name == 'HYPER': hyper = HYPER(card_obj, comment) self.hyper[hyper.pid] = hyper return elif card_name == 'FLOW': flow = FLOW(card_obj, comment) self.flow[flow.flow_id] = flow return BDF.add_card(self, card, card_name, comment=comment, is_list=True)
def add_card(self, card_lines, card_name, comment=''): card = to_fields(card_lines, card_name) card = [interpret_value(val) for val in card] card = BDFCard(card) #if card_name == "LOAD": rec = [] for item in card: if isinstance(item, int): rec.append(1) elif isinstance(item, float): rec.append(1.0) else: rec.append(item) #print(type(c), c) #print("*", rec) rec_str = str(rec) if not rec_str in self.card_set: #self.new_bdf.add_card(card, card_name, icard, old_card_obj) #print(card) self.card_set.add(rec_str)
def add_card(self, card_lines, card_name, comment=''): card = to_fields(card_lines, card_name) card = [interpret_value(val) for val in card] card = BDFCard(card) #if cardName == "LOAD": rec = [] for item in card: item_type = type(item) if item_type == int: item = 1 #print("int") elif item_type == float: item = 1.0 #print("float") rec.append(item) #print(type(c), c #print("*", rec) rec_str = str(rec) if not rec_str in self.card_set: #self.newBDF.add_card(card, cardName, iCard, old_card_obj) #print(card) self.card_set.add(rec_str)
def add_card(self, card_lines, card_name, comment=''): card = to_fields(card_lines, card_name) card = [interpret_value(val) for val in card] card = BDFCard(card) #if cardName == "LOAD": rec = [] for item in card: item_type = type(item) if item_type == int: item = 1 #print "int" elif item_type == float: item = 1.0 #print "float" rec.append(item) #print type(c), c #print "*", rec rec_str = str(rec) if not rec_str in self.card_set: #self.newBDF.add_card(card, cardName, iCard, old_card_obj) #print(card) self.card_set.add(rec_str)
def add_card(self, card_lines, card_name, comment='', is_list=True): card_name = card_name.upper() self._increase_card_count(card_name) if card_name in ['DEQATN']: card_obj = card_lines card = card_lines else: if is_list: fields = card_lines else: fields = to_fields(card_lines, card_name) # apply OPENMDAO syntax if self._is_dynamic_syntax: fields = [ self._parse_dynamic_syntax(field) if '%' in field[0:1] else field for field in fields ] card = wipe_empty_fields([ interpret_value(field, fields) if field is not None else None for field in fields ]) else: # leave everything as strings card = wipe_empty_fields(fields) card_obj = BDFCard(card) if card_name == 'HYPER': hyper = HYPER(card_obj, comment) self.hyper[hyper.pid] = hyper return elif card_name == 'FLOW': flow = FLOW(card_obj, comment) self.flow[flow.flow_id] = flow return BDF.add_card(self, card, card_name, comment=comment, is_list=True)
def add_card(self, card_lines, card_name, comment='', is_list=True): """ Adds a card object to the BDF object using a streaming approach. Parameters ---------- card_lines : List[str] the list of the card fields >>> ['GRID,1,2',] # (is_list = False) >>> ['GRID',1,2,] # (is_list = True; default) card_name : str the card_name -> 'GRID' comment : str; default=True an optional the comment for the card is_list : bool; default=True changes card_lines from a list of lines to a list of fields Returns ------- card_object : BDFCard() the card object representation of card .. note:: this is a very useful method for interfacing with the code .. note:: the cardObject is not a card-type object...so not a GRID card or CQUAD4 object. It's a BDFCard Object. However, you know the type (assuming a GRID), so just call the *mesh.Node(nid)* to get the Node object that was just created. .. warning:: cardObject is not returned """ if comment: self.bdf_out_file.write(comment) if card_name in ['DEQATN']: card_obj = card_lines card = card_lines #print("card =", '\n'.join(card_lines)) self.bdf_out_file.write('\n'.join(card_lines)) else: if is_list: fields = card_lines else: fields = to_fields(card_lines, card_name) # apply OPENMDAO syntax if self._is_dynamic_syntax: fields = [self._parse_dynamic_syntax(field) if '%' in field[0:1] else field for field in fields] card = wipe_empty_fields([interpret_value(field, fields) if field is not None else None for field in fields]) #print(card) card_obj = BDFCard(card) self.bdf_out_file.write(print_card_8(card_obj)) #for reject_card in self.reject_cards: #try: #print('comment =', comment) #except RuntimeError: #for field in reject_card: #if field is not None and '=' in field: #raise SyntaxError('cannot reject equal signed ' # 'cards\ncard=%s\n' % reject_card) #raise #self.reject_cards.append(card) #print('rejecting processed auto=rejected %s' % card) return card_obj
def add_card(self, card_lines, card_name, comment='', is_list=True): """ Adds a card object to the BDF object using a streaming approach. :param self: the BDF object :param card_lines: the list of the card fields >>> ['GRID,1,2',] # (is_list = False) >>> ['GRID',1,2,] # (is_list = True; default) :param card_name: the card_name -> 'GRID' :param comment: an optional the comment for the card :param is_list: changes card_lines from a list of lines to a list of fields :returns card_object: the card object representation of card .. note:: this is a very useful method for interfacing with the code .. note:: the cardObject is not a card-type object...so not a GRID card or CQUAD4 object. It's a BDFCard Object. However, you know the type (assuming a GRID), so just call the *mesh.Node(nid)* to get the Node object that was just created. .. warning:: cardObject is not returned """ if comment: self.bdf_out_file.write(comment) if card_name in ['DEQATN']: card_obj = card_lines card = card_lines #print("card =", '\n'.join(card_lines)) self.bdf_out_file.write('\n'.join(card_lines)) else: if is_list: fields = card_lines else: fields = to_fields(card_lines, card_name) # apply OPENMDAO syntax if self._is_dynamic_syntax: fields = [ self._parse_dynamic_syntax(field) if '%' in field[0:1] else field for field in fields ] card = wipe_empty_fields([ interpret_value(field, fields) if field is not None else None for field in fields ]) #print(card) card_obj = BDFCard(card) self.bdf_out_file.write(print_card_8(card_obj)) #for reject_card in self.reject_cards: #try: #print('comment =', comment) #except RuntimeError: #for field in reject_card: #if field is not None and '=' in field: #raise SyntaxError('cannot reject equal signed ' # 'cards\ncard=%s\n' % reject_card) #raise #self.reject_cards.append(card) #print('rejecting processed auto=rejected %s' % card) return card_obj