@@ -245,9 +245,9 @@ def add_param_object(self, param: PARAM, allow_overwrites: bool=False) -> None:
245245 model = self .model
246246 if key in model .params and not allow_overwrites :
247247 if not param == model .params [key ]:
248- #if param.key in self.params:
249- # msg = 'key=%s param=%s old_param=%s' % (key, param, self.params[key])
250- # raise KeyError(msg)
248+ # if param.key in self.params:
249+ # msg = 'key=%s param=%s old_param=%s' % (key, param, self.params[key])
250+ # raise KeyError(msg)
251251 model .log .warning ('key=%s param=%s old_param=%s' %
252252 (key , param , model .params [key ]))
253253 model .params [key ] = param
@@ -471,6 +471,7 @@ def add_element_object(self, elem: Element,
471471 # already handled
472472 #model._type_to_id_map[elem.type].append(key)
473473 else :
474+ model .log .error (f'duplicate element { key } :\n { model .elements [key ]} with:\n { elem } ' )
474475 model ._duplicate_elements .append (elem )
475476 if model ._stop_on_duplicate_error :
476477 model .pop_parse_errors ()
@@ -484,9 +485,9 @@ def add_ao_object(self, elem_flag: CBARAO,
484485 assert key > 0 , 'eid=%s must be positive; elem_flag=\n %s' % (key , elem_flag )
485486 if key in model .ao_element_flags and not allow_overwrites :
486487 if not elem_flag == model .ao_element_flags [key ]:
487- #self.model._duplicate_elements.append(elem_flag)
488- #if self.model._stop_on_duplicate_error:
489- # self.model.pop_parse_errors()
488+ # self.model._duplicate_elements.append(elem_flag)
489+ # if self.model._stop_on_duplicate_error:
490+ # self.model.pop_parse_errors()
490491 assert elem_flag .eid not in self .model .ao_element_flags , 'eid=%s\n old_ao_element=\n %snew_ao_element=\n %s' % (
491492 elem_flag .eid , model .ao_element_flags [elem_flag .eid ], elem_flag )
492493 else :
@@ -888,14 +889,37 @@ def add_coord_object(self, coord: Coord, # CORD3G
888889 allow_overwrites : bool = False ) -> None :
889890 """adds a Coord object"""
890891 key = coord .cid
892+ model = self .model
891893 assert coord .cid > - 1 , 'cid=%s coord=\n %s' % (key , coord )
892- if key in self .model .coords :
893- #if not allow_overwrites:
894- if not coord == self .model .coords [key ]:
895- self .model ._duplicate_coords .append (coord )
894+ # add_object_to_dict_no_dupes(model, key, 'coords', coord, model.coords,
895+ # model._duplicate_coords, allow_overwrites)
896+
897+ # v1.4
898+ # if key in self.model.coords:
899+ # #if not allow_overwrites:
900+ # if not coord == self.model.coords[key]:
901+ # self.model._duplicate_coords.append(coord)
902+ # else:
903+ # self.model.coords[key] = coord
904+ # self.model._type_to_id_map[coord.type].append(key)
905+
906+ if key not in model .coords :
907+ model .coords [key ] = coord
908+ model ._type_to_id_map [coord .type ].append (key )
909+ elif coord == model .coords [key ]:
910+ model .log .warning (f'replacing equivalent coord:\n { coord } ' )
911+ elif allow_overwrites :
912+ model .log .warning (f'replacing coord:\n { model .coords [key ]} with:\n { coord } ' )
913+ model .coords [key ] = coord
914+ # already handled
915+ #model._type_to_id_map[prop.type].append(key)
896916 else :
897- self .model .coords [key ] = coord
898- self .model ._type_to_id_map [coord .type ].append (key )
917+ # error, but no crash b/c op2
918+ model .log .error (f'duplicate coord { key } :\n { model .coords [key ]} with:\n { coord } ' )
919+ # duplicate_list.append(obj)
920+ # if model._stop_on_duplicate_error:
921+ # model.pop_parse_errors()
922+ #raise RuntimeError('pid=%s\nold_prop=\n%snew_prop=\n%s' % (prop.pid, model.properties[key], prop))
899923
900924 def add_matcid_object (self , matcid : MATCID ) -> None :
901925 """adds a MATCID object"""
@@ -1115,18 +1139,18 @@ def add_aeros_object(self, aeros: AEROS) -> None:
11151139 # only one AEROS card allowed
11161140 assert self .model .aeros is None , '\n aeros=\n %s old=\n %s' % (aeros , self .model .aeros )
11171141 self .model .aeros = aeros
1118- #self.model._type_to_id_map[aeros.type].append(key)
1119-
1120- #def add_aeroz_object(self, aeroz: AEROZ) -> None:
1121- # """adds an AEROZ object"""
1122- # key = aeroz.sid
1123- # if key in self.model.aeroz and not allow_overwrites:
1124- # if not aeroz == self.model.zona.aeroz[key]:
1125- # assert key not in self.model.aeroz, 'AEROZ.sid=%s\nold=\n%snew=\n%s' % (key, self.model.aeroz[key], aeroz)
1126- # else:
1127- # assert key > 0, 'sid=%s method=\n%s' % (key, aefact)
1128- # self.model.aeroz[key] = aeroz
1129- # self.model._type_to_id_map[aeroz.type].append(key)
1142+ # self.model._type_to_id_map[aeros.type].append(key)
1143+
1144+ # def add_aeroz_object(self, aeroz: AEROZ) -> None:
1145+ # """adds an AEROZ object"""
1146+ # key = aeroz.sid
1147+ # if key in self.model.aeroz and not allow_overwrites:
1148+ # if not aeroz == self.model.zona.aeroz[key]:
1149+ # assert key not in self.model.aeroz, 'AEROZ.sid=%s\nold=\n%snew=\n%s' % (key, self.model.aeroz[key], aeroz)
1150+ # else:
1151+ # assert key > 0, 'sid=%s method=\n%s' % (key, aefact)
1152+ # self.model.aeroz[key] = aeroz
1153+ # self.model._type_to_id_map[aeroz.type].append(key)
11301154
11311155 def add_baror_object (self , baror : BAROR ) -> None :
11321156 """adds an BAROR object"""
@@ -1142,17 +1166,17 @@ def add_beamor_object(self, beamor: BEAMOR) -> None:
11421166 if self .model .beamor is None :
11431167 self .model .beamor = beamor
11441168
1145- #def add_axic_object(self, axic: AXIC) -> None:
1146- # """adds an AXIC object"""
1147- # # only one AXIC card allowed
1148- # assert self.model.axic is None, '\naxic=\n%s old=\n%s' % (axic, self.model.axic)
1149- # self.model.axic = axic
1150-
1151- #def add_axif_object(self, axif: AXIF) -> None:
1152- # """adds an AXIF object"""
1153- # # only one AXIC card allowed
1154- # assert self.model.axif is None, '\naxif=\n%s old=\n%s' % (axif, self.model.axif)
1155- # self.model.axif = axif
1169+ # def add_axic_object(self, axic: AXIC) -> None:
1170+ # """adds an AXIC object"""
1171+ # # only one AXIC card allowed
1172+ # assert self.model.axic is None, '\naxic=\n%s old=\n%s' % (axic, self.model.axic)
1173+ # self.model.axic = axic
1174+ #
1175+ # def add_axif_object(self, axif: AXIF) -> None:
1176+ # """adds an AXIF object"""
1177+ # # only one AXIC card allowed
1178+ # assert self.model.axif is None, '\naxif=\n%s old=\n%s' % (axif, self.model.axif)
1179+ # self.model.axif = axif
11561180
11571181 def add_acmodl_object (self , acmodl : ACMODL ) -> None :
11581182 """adds a ACMODL object"""
@@ -1360,16 +1384,16 @@ def add_dconstr_object(self, dconstr: DCONSTR | DCONADD) -> None:
13601384 self .model .dconstrs [key ] = [dconstr ]
13611385 self .model ._type_to_id_map [dconstr .type ].append (key )
13621386
1363- #def add_DCONADD (self, dconadd, allow_overwrites: bool=False) -> None:
1364- # key = dconadd.oid
1365- # if key in self.model.dconstrs and not allow_overwrites:
1366- # if not dconadd == self.model.dconstrs[key]:
1367- # assert key not in self.model.dconstrs, 'DCONADD=%s old=\n%snew=\n%s' % (
1368- # key, self.model.dconstrs[key], dconadd)
1369- # else:
1370- # assert key > 0, 'dcid=%s dconadd=%s' % (key, dconadd)
1371- # self.model.dconstrs[key] = dconadd
1372- # self.model._type_to_id_map[dconadd.type].append(key)
1387+ # def add_dconadd (self, dconadd, allow_overwrites: bool=False) -> None:
1388+ # key = dconadd.oid
1389+ # if key in self.model.dconstrs and not allow_overwrites:
1390+ # if not dconadd == self.model.dconstrs[key]:
1391+ # assert key not in self.model.dconstrs, 'DCONADD=%s old=\n%snew=\n%s' % (
1392+ # key, self.model.dconstrs[key], dconadd)
1393+ # else:
1394+ # assert key > 0, 'dcid=%s dconadd=%s' % (key, dconadd)
1395+ # self.model.dconstrs[key] = dconadd
1396+ # self.model._type_to_id_map[dconadd.type].append(key)
13731397
13741398 def add_desvar_object (self , desvar : DESVAR ) -> None :
13751399 """adds a DESVAR object"""
@@ -1806,7 +1830,7 @@ def _add_value_to_dict(result: dict[int, Any], key: int, card: Any,
18061830
18071831
18081832def add_object_to_dict (model : BDF , key : int ,
1809- obj_name : str ,
1833+ obj_name : str ,
18101834 obj : BaseCard ,
18111835 obj_dict : dict [int , BaseCard ],
18121836 allow_overwrites : bool ) -> None :
@@ -1847,13 +1871,15 @@ def add_object_to_dict(model: BDF, key: int,
18471871 # already handled
18481872 #model._type_to_id_map[prop.type].append(key)
18491873 else :
1874+ model .log .error (f'duplicate { obj_name } { key } :\n { obj_dict [key ]} with:\n { obj } ' )
18501875 # duplicate_list.append(obj)
18511876 # if model._stop_on_duplicate_error:
18521877 # model.pop_parse_errors()
18531878 raise RuntimeError (f'id={ key !r} \n '
18541879 f'old_{ obj_name } =\n { str (obj_dict [key ])} '
18551880 f'new_{ obj_name } =\n { str (obj )} ' )
18561881
1882+
18571883def add_object_to_dict_no_dupes (model : BDF , key : int , obj_name : str ,
18581884 obj : BaseCard , obj_dict : dict [int , BaseCard ],
18591885 duplicate_list : list [BaseCard ],
@@ -1901,6 +1927,7 @@ def add_object_to_dict_no_dupes(model: BDF, key: int, obj_name: str,
19011927 # already handled
19021928 #model._type_to_id_map[prop.type].append(key)
19031929 else :
1930+ model .log .error (f'duplicate { obj_name } { key } :\n { obj_dict [key ]} with:\n { obj } ' )
19041931 duplicate_list .append (obj )
19051932 if model ._stop_on_duplicate_error :
19061933 model .pop_parse_errors ()
0 commit comments