Skip to content

Commit

Permalink
adding duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Jan 14, 2025
1 parent 1880ae7 commit 493e0cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pyNastran/dev/bdf_vectorized3/cards/base_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,17 @@ def sort_duplicates(card: VectorizedBaseCard) -> None:
#assert (iarg - uarg).sum() == 0, (iarg - uarg).sum()

is_duplicate_ids = (len(ids_sorted) != len(uids_sorted))
if is_duplicate_ids:
model = card.model
if is_duplicate_ids and card.type in model.allow_overwrites_set:
#print(f'ids_sorted = {ids_sorted}')
#print(f'uids_sorted = {uids_sorted}')
idx = np.searchsorted(ids_sorted, uids_sorted, side='right') - 1
assert np.array_equal(ids_sorted[idx], uids_sorted)
#print(f'idx = {idx}')
card.__apply_slice__(card, idx)
# card._is_sorted = True
# return
elif is_duplicate_ids:
# Now that we've sorted the ids, we'll take the delta id with the next id.
# We check the two neighoring values when there is a duplicate,
# so if they're they same in xyz, cp, cd, etc., the results are the same
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@


class TestCoords(unittest.TestCase):
def test_grid_repeated(self):
model = BDF(debug=False, log=None, mode='msc')
model.allow_overwrites_set = {'GRID'}
model._make_card_parser()
model.add_grid(1, [0., 0., 0.], comment='a')
model.add_grid(2, [1., 0., 0.], comment='')
model.add_grid(1, [2., 0., 0.], comment='a')
model.parse_cards()

def test_ricoord(self):
model = BDF(debug=False, log=None, mode='msc')
fields = ['CORD1R', '1', '1', '101', '2']
Expand Down

0 comments on commit 493e0cd

Please sign in to comment.