Skip to content

Commit

Permalink
working on lax parser
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Jan 14, 2025
1 parent 235382c commit 507685e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyNastran/dev/bdf_vectorized3/bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def __init__(self, debug: str | bool | None=True,
self._remove_disabled_cards = False

self.is_strict_card_parser = True
self.allow_overwrites_set = set([])

# file management parameters
self.active_filenames: list[str] = []
Expand Down
11 changes: 11 additions & 0 deletions pyNastran/dev/bdf_vectorized3/cards/base_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def _slice_comment(self, new_obj: VectorizedBaseCard, i: np.ndarray) -> None:
#new_ids = self.node_id[i]
try:
# intersect the ids we're slicing with the existing ones
if not i.max() <= self._ids.max():
raise RuntimeError(f'_slice_comment: i={i}; _ids={self._ids}')
new_ids = self._ids[i]
common_ids = np.intersect1d(list(self.comment.keys()), new_ids)
new_obj.comment = {nid: self.comment[nid] for nid in common_ids}
Expand Down Expand Up @@ -1009,6 +1011,15 @@ def sort_duplicates(card: VectorizedBaseCard) -> None:
uids_sorted = np.unique(ids_sorted)

if not np.array_equal(uarg, iarg) or len(ids) != len(uids_sorted):
print(f'card.type = {card.type}')
model = card.model
if card.type in model.allow_overwrites_set:
#isort = np.searchsorted(ids_sorted, uarg)
model.log.warning('picking lower indicies (first added to model)')
card.__apply_slice__(card, uids_sorted)
card._is_sorted = True
return

# we have duplicate/unsorted nodes
#
#print(iarg.tolist())
Expand Down
1 change: 1 addition & 0 deletions pyNastran/dev/bdf_vectorized3/cards/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ def slice_card_by_index(self, i: np.ndarray, sort_index: bool=False) -> GRID:
return grid

def __apply_slice__(self, grid: GRID, i: np.ndarray) -> None:
assert grid.n <= i.max(), 'GRID.n <=i.max()'
self._slice_comment(grid, i)

grid.n = len(i)
Expand Down
1 change: 1 addition & 0 deletions pyNastran/dev/bdf_vectorized3/nastran_io3.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ def get_bdf_geometry(self, bdf_filename: PathLike | BDF,
else:
model = BDF(debug=True, log=log, mode='msc')
model.is_strict_card_parser = False
model.allow_overwrites_set = {'GRID', 'CONM2'}
model.idtype = 'int64'
model.read_bdf(bdf_filename)

Expand Down
7 changes: 6 additions & 1 deletion pyNastran/dev/bdf_vectorized3/test/test_bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,12 @@ def run_and_compare_fems(
assert isinstance(bdf_model, str) and os.path.exists(bdf_model), f'{bdf_model!r} doesnt exist\n%s' % print_bad_path(bdf_model)
fem1 = BDFv(debug=debug, log=log)
fem1.idtype = 'int64'
fem1.is_strict_card_parser = False
is_lax_parser = True
if is_lax_parser:
fem1.log.warning('using lax card parser')
fem1.is_strict_card_parser = False
fem1.allow_overwrites_set = {'GRID', 'CONM2'}
fem1._make_card_parser()
fem1.run_testing_checks = True

_setup_fem(fem1, debug, log, version,
Expand Down

0 comments on commit 507685e

Please sign in to comment.