Skip to content

Commit 6ac7149

Browse files
committed
more testing
1 parent 62c57bf commit 6ac7149

File tree

7 files changed

+79
-111
lines changed

7 files changed

+79
-111
lines changed

pyNastran/bdf/bdf.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from io import StringIO, IOBase
2121
from pathlib import PurePath
2222
from functools import wraps
23-
#from functools import partial
2423
from collections import defaultdict
2524
import traceback
2625

@@ -29,16 +28,14 @@
2928
from pickle import load, dump, dumps # type: ignore
3029

3130
import numpy as np # type: ignore
32-
# from cpylog import get_logger2 as get_logger, CPYLOG_VERSION
33-
# if CPYLOG_VERSION > (1, 6, 0):
34-
# from cpylog import get_logger
3531

3632
from pyNastran.utils import PathLike, object_attributes, check_path, deprecated as _deprecated
3733
from .utils import parse_patran_syntax
3834
from .bdf_interface.utils import (
3935
_parse_pynastran_header, to_fields, to_fields_line0,
4036
parse_executive_control_deck,
4137
fill_dmigs, _get_card_name, _parse_dynamic_syntax,
38+
_prep_comment,
4239
)
4340
from pyNastran.bdf.bdf_interface.attributes import map_version, map_update
4441
from pyNastran.bdf.bdf_interface.add_card import CARD_MAP
@@ -5297,16 +5294,6 @@ def read_bdf(bdf_filename: Optional[PathLike]=None, validate: bool=True,
52975294
return model
52985295

52995296

5300-
def _prep_comment(comment: str) -> str:
5301-
return comment.rstrip()
5302-
#print('comment = %r' % comment)
5303-
#comment = ' this\n is\n a comment\n'
5304-
#print(comment.rstrip('\n').split('\n'))
5305-
#sline = [comment[1:] if len(comment) and comment[0] == ' ' else comment
5306-
#for comment in comment.rstrip().split('\n')]
5307-
#print('sline = ', sline)
5308-
5309-
53105297
def _check_replicated_cards(replicated_cards):
53115298
"""helper method for ``parse_cards_list``"""
53125299
replicated_card_old = []

pyNastran/bdf/bdf_interface/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,3 +700,14 @@ def fill_dmigs(model: BDF) -> None:
700700

701701
# empty the _dmig_temp variable
702702
model._dmig_temp = defaultdict(list)
703+
704+
705+
def _prep_comment(comment: str) -> str:
706+
"""cleans up the comment"""
707+
return comment.rstrip()
708+
#print('comment = %r' % comment)
709+
#comment = ' this\n is\n a comment\n'
710+
#print(comment.rstrip('\n').split('\n'))
711+
#sline = [comment[1:] if len(comment) and comment[0] == ' ' else comment
712+
#for comment in comment.rstrip().split('\n')]
713+
#print('sline = ', sline)

pyNastran/dev/bdf_vectorized/bdf.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from pyNastran.bdf.case_control_deck import CaseControlDeck
3939

40-
from pyNastran.bdf.bdf_interface.utils import fill_dmigs
40+
from pyNastran.bdf.bdf_interface.utils import fill_dmigs, _prep_comment
4141
from pyNastran.bdf.bdf_interface.bdf_card import BDFCard
4242
from pyNastran.dev.bdf_vectorized.bdf_interface2.write_mesh import WriteMesh
4343
from pyNastran.dev.bdf_vectorized.bdf_interface2.get_card import GetMethods
@@ -3543,16 +3543,6 @@ def _verify_bdf(self, xref=None):
35433543
'SETS', 'CONTACT', 'REJECTS', 'REJECT_LINES',
35443544
'PROPERTIES_MASS', 'MASSES')
35453545

3546-
def _prep_comment(comment):
3547-
return comment.rstrip()
3548-
#print('comment = %r' % comment)
3549-
#comment = ' this\n is\n a comment\n'
3550-
#print(comment.rstrip('\n').split('\n'))
3551-
#sline = [comment[1:] if len(comment) and comment[0] == ' ' else comment
3552-
#for comment in comment.rstrip().split('\n')]
3553-
#print('sline = ', sline)
3554-
#asdh
3555-
35563546
def _clean_comment(comment):
35573547
"""
35583548
Removes specific pyNastran comment lines so duplicate lines aren't

pyNastran/dev/bdf_vectorized3/bdf.py

Lines changed: 51 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@
3232

3333
from pyNastran.utils import object_attributes, check_path, PathLike
3434
from pyNastran.utils.numpy_utils import (
35-
integer_types, float_types)
35+
integer_types)
3636
from pyNastran.bdf.utils import parse_patran_syntax
3737
from pyNastran.bdf.bdf_interface.utils import (
3838
_parse_pynastran_header, to_fields, parse_executive_control_deck,
3939
fill_dmigs, _get_card_name, _parse_dynamic_syntax,
40+
_prep_comment,
4041
)
4142
from pyNastran.bdf.bdf_interface.add_card import CARD_MAP
4243
from pyNastran.bdf.bdf_interface.replication import (
@@ -486,16 +487,9 @@
486487
def load_bdf_object(obj_filename:str, xref: bool=True, log=None, debug: bool=True):
487488
model = BDF(log=log, debug=debug)
488489
model.load(obj_filename=obj_filename)
489-
model.cross_reference(xref=xref, xref_nodes=True, xref_elements=True,
490-
xref_nodes_with_elements=True,
491-
xref_properties=True,
492-
xref_masses=True,
493-
xref_materials=True,
494-
xref_loads=True,
495-
xref_constraints=True,
496-
xref_aero=True,
497-
xref_sets=True,
498-
xref_optimization=True)
490+
model.cross_reference(
491+
run_setup=True,
492+
run_geom_check=False)
499493
return model
500494

501495

@@ -1367,7 +1361,8 @@ def read_bdf(self, bdf_filename: Optional[PathLike]=None,
13671361
>>> g1 = bdf.Node(1)
13681362
>>> print(g1.get_position())
13691363
[10.0, 12.0, 42.0]
1370-
>>> bdf.write_card(bdf_filename2)
1364+
>>> bdf_filename_out = 'fem_out.bdf'
1365+
>>> bdf.write_card(bdf_filename_out)
13711366
>>> print(bdf.card_stats())
13721367
13731368
---BDF Statistics---
@@ -1954,6 +1949,7 @@ def set_dynamic_syntax(self, dict_of_vars: dict[str, int | float | str]) -> None
19541949
>>> dict_of_vars = {'xVar': 1.0, 'yVar', 2.0, 'zVar':3.0}
19551950
>>> bdf = BDF()
19561951
>>> bdf.set_dynamic_syntax(dict_of_vars)
1952+
>>> bdf_filename = 'fem.bdf'
19571953
>>> bdf.read_bdf(bdf_filename, xref=True)
19581954
19591955
Notes
@@ -3071,18 +3067,18 @@ def _prepare_dmiji(self, unused_card: list[str], card_obj: BDFCard,
30713067
assert isinstance(ifile, integer_types), ifile
30723068
return self._prepare_dmix(DMIJI, self._add_methods.add_dmiji_object, card_obj, ifile, comment=comment)
30733069

3074-
def _prepare_ringfl(self, unused_card: list[str], card_obj: BDFCard,
3075-
ifile: int, comment: str='') -> None:
3076-
"""adds a RINGFL"""
3077-
assert isinstance(ifile, integer_types), ifile
3078-
rings = [RINGFL.add_card(card_obj, icard=0, comment=comment)]
3079-
if card_obj.field(3):
3080-
rings.append(RINGFL.add_card(card_obj, icard=1, comment=comment))
3081-
if card_obj.field(5):
3082-
rings.append(RINGFL.add_card(card_obj, icard=2, comment=comment))
3083-
for ring in rings:
3084-
self._add_methods.add_ringfl_object(ring)
3085-
return rings
3070+
# def _prepare_ringfl(self, unused_card: list[str], card_obj: BDFCard,
3071+
# ifile: int, comment: str='') -> None:
3072+
# """adds a RINGFL"""
3073+
# assert isinstance(ifile, integer_types), ifile
3074+
# rings = [RINGFL.add_card(card_obj, icard=0, comment=comment)]
3075+
# if card_obj.field(3):
3076+
# rings.append(RINGFL.add_card(card_obj, icard=1, comment=comment))
3077+
# if card_obj.field(5):
3078+
# rings.append(RINGFL.add_card(card_obj, icard=2, comment=comment))
3079+
# for ring in rings:
3080+
# self._add_methods.add_ringfl_object(ring)
3081+
# return rings
30863082

30873083
def _prepare_acmodl(self, unused_card: list[str], card_obj: BDFCard,
30883084
ifile: int, comment: str='') -> None:
@@ -3400,13 +3396,13 @@ def _add_card_helper_lax(self, card_obj: BDFCard, card: list[str],
34003396
raise DisabledCardError(f'stopping on card={card_name}')
34013397

34023398
if card_name in self._card_parser:
3403-
34043399
card_class, add_card_function = self._card_parser[card_name]
3405-
if hasattr(card_class, 'add_card_lax'):
3406-
class_instance = card_class.add_card_lax(card_obj, comment=comment)
3407-
else:
3408-
3409-
class_instance = card_class.add_card(card_obj, comment=comment)
3400+
add_card = getattr(card_class, 'add_card_lax') if hasattr(card_class, 'add_card_lax') else getattr(card_class, 'add_card')
3401+
class_instance = add_card(card_obj, comment=comment)
3402+
# if hasattr(card_class, 'add_card_lax'):
3403+
# class_instance = card_class.add_card_lax(card_obj, comment=comment)
3404+
# else:
3405+
# class_instance = card_class.add_card(card_obj, comment=comment)
34103406
add_card_function(class_instance)
34113407

34123408
elif card_name in self._card_parser_prepare:
@@ -3449,11 +3445,16 @@ def _add_card_helper(self, card_obj: BDFCard, card: list[str],
34493445

34503446
if card_name in self._card_parser:
34513447
card_class, add_card_function = self._card_parser[card_name]
3448+
add_card = (
3449+
getattr(card_class, 'add_card_lax')
3450+
if not self.is_strict_card_parser and hasattr(card_class, 'add_card_lax')
3451+
else getattr(card_class, 'add_card'))
34523452
try:
3453-
if not self.is_strict_card_parser and hasattr(card_class, 'add_card_lax'):
3454-
class_instance = card_class.add_card_lax(card_obj, comment=comment)
3455-
else:
3456-
class_instance = card_class.add_card(card_obj, comment=comment)
3453+
class_instance = add_card(card_obj, comment=comment)
3454+
# if not self.is_strict_card_parser and hasattr(card_class, 'add_card_lax'):
3455+
# class_instance = card_class.add_card_lax(card_obj, comment=comment)
3456+
# else:
3457+
# class_instance = card_class.add_card(card_obj, comment=comment)
34573458
card_idi = add_card_function(class_instance)
34583459
if card_name not in OBJ_CARDS: # pragma: no cover
34593460
if not isinstance(card_idi, int):
@@ -3578,6 +3579,7 @@ def get_displacement_index_xyz_cp_cd(self, fdtype: str='float64',
35783579
# assume GRID 1 has a CD=10, CP=0
35793580
# assume GRID 2 has a CD=10, CP=0
35803581
# assume GRID 5 has a CD=50, CP=0
3582+
>>> model = BDF()
35813583
>>> model.point_ids
35823584
[1, 2, 5]
35833585
>>> out = model.get_displacement_index_xyz_cp_cd()
@@ -3690,6 +3692,7 @@ def get_xyz_in_coord_array(self, cid: int=0,
36903692
36913693
Examples
36923694
--------
3695+
>>> model = BDF()
36933696
>>> out = model.get_xyz_in_coord_array(cid=0, fdtype='float64', idtype='int32')
36943697
>>> nid_cp_cd, xyz_cid, xyz_cp, icd_transform, icp_transform = out
36953698
"""
@@ -3740,6 +3743,8 @@ def transform_xyzcp_to_xyz_cid(self, xyz_cp: np.ndarray,
37403743
# assume GRID 1 has a CD=10, CP=0
37413744
# assume GRID 2 has a CD=10, CP=0
37423745
# assume GRID 5 has a CD=50, CP=1
3746+
3747+
>>> model = BDF()
37433748
>>> model.point_ids
37443749
[1, 2, 5]
37453750
>>> out = model.get_displacement_index_xyz_cp_cd()
@@ -3910,6 +3915,8 @@ def get_displacement_index(self) -> tuple[Any, Any, dict[int, Any]]:
39103915
# assume GRID 1 has a CD=10
39113916
# assume GRID 2 has a CD=10
39123917
# assume GRID 5 has a CD=50
3918+
3919+
>>> model = BDF()
39133920
>>> model.point_ids
39143921
[1, 2, 5]
39153922
>>> icd_transform = model.get_displacement_index()
@@ -3948,8 +3955,10 @@ def increase_card_count(self, card_name: str, count_num: int=1) -> None:
39483955
count_num : int, optional
39493956
the amount to increment by (default=1)
39503957
3951-
>>> bdf.read_bdf(bdf_filename)
3952-
>>> bdf.card_count['GRID']
3958+
>>> model = BDF()
3959+
>>> bdf_filename = 'fem.bdf'
3960+
>>> model.read_bdf(bdf_filename)
3961+
>>> model.card_count['GRID']
39533962
50
39543963
39553964
"""
@@ -4437,7 +4446,8 @@ def _read_bdf_cards(self, bdf_filename: Optional[str]=None,
44374446
>>> g1 = bdf.Node(1)
44384447
>>> print(g1.get_position())
44394448
[10.0, 12.0, 42.0]
4440-
>>> bdf.write_card(bdf_filename2)
4449+
>>> bdf_filename_out = 'fem_out.bdf'
4450+
>>> bdf.write_card(bdf_filename_out)
44414451
>>> print(bdf.card_stats())
44424452
44434453
---BDF Statistics---
@@ -4801,7 +4811,8 @@ def read_bdf(bdf_filename: Optional[PathLike]=None, validate: bool=True, xref: b
48014811
>>> g1 = bdf.Node(1)
48024812
>>> print(g1.get_position())
48034813
[10.0, 12.0, 42.0]
4804-
>>> bdf.write_card(bdf_filename2)
4814+
>>> bdf_filename_out = 'fem_out.bdf'
4815+
>>> bdf.write_card(bdf_filename_out)
48054816
>>> print(bdf.card_stats())
48064817
48074818
---BDF Statistics---
@@ -4817,7 +4828,7 @@ def read_bdf(bdf_filename: Optional[PathLike]=None, validate: bool=True, xref: b
48174828
"""
48184829
model = BDF(log=log, debug=debug, mode=mode)
48194830
if read_cards and skip_cards:
4820-
msg = 'read_cards=%s skip_cards=%s cannot be used at the same time'
4831+
msg = f'read_cards={read_cards} skip_cards={skip_cards} cannot be used at the same time'
48214832
raise NotImplementedError(msg)
48224833
if skip_cards:
48234834
model.disable_cards(skip_cards)
@@ -4831,53 +4842,9 @@ def read_bdf(bdf_filename: Optional[PathLike]=None, validate: bool=True, xref: b
48314842
xref=xref, punch=punch, read_includes=True,
48324843
save_file_structure=save_file_structure,
48334844
encoding=encoding)
4834-
4835-
#if 0:
4836-
### TODO: remove all the extra methods
4837-
4838-
#keys_to_suppress = []
4839-
#method_names = model.object_methods(keys_to_skip=keys_to_suppress)
4840-
4841-
#methods_to_remove = [
4842-
#'_process_card', 'read_bdf', 'disable_cards', 'set_dynamic_syntax',
4843-
#'create_card_object', 'create_card_object_fields', 'create_card_object_list',
4844-
4845-
#'add_NLPARM', 'add_NLPCI',
4846-
#'add_PARAM',',
4847-
4848-
#'add_card', 'add_card_fields', 'add_card_lines', 'add_cmethod', 'add_constraint',
4849-
#'add_convection_property', 'add_creep_material',
4850-
#'add_material_dependence', 'add_method',
4851-
#'add_random_table',
4852-
#'add_table', 'add_table_sdamping', 'add_thermal_BC', 'add_thermal_element',
4853-
4854-
#'set_as_msc',
4855-
#'set_as_nx',
4856-
4857-
#'pop_parse_errors',
4858-
#'set_error_storage',
4859-
#'is_reject',
4860-
#]
4861-
#for method_name in method_names:
4862-
#if method_name not in methods_to_remove + keys_to_suppress:
4863-
##print(method_name)
4864-
#pass
4865-
#else:
4866-
### TODO: doesn't work...
4867-
##delattr(model, method_name)
4868-
#pass
4869-
#model.get_bdf_stats()
48704845
return model
48714846

4872-
def _prep_comment(comment):
4873-
return comment.rstrip()
4874-
#print('comment = %r' % comment)
4875-
#comment = ' this\n is\n a comment\n'
4876-
#print(comment.rstrip('\n').split('\n'))
4877-
#sline = [comment[1:] if len(comment) and comment[0] == ' ' else comment
4878-
#for comment in comment.rstrip().split('\n')]
4879-
#print('sline = ', sline)
4880-
def _check_replicated_cards(replicated_cards):
4847+
def _check_replicated_cards(replicated_cards) -> None:
48814848
"""helper method for ``parse_cards_list``"""
48824849
replicated_card_old = []
48834850
try:

pyNastran/dev/bdf_vectorized3/cards/test/test_vector_aero.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ def test_freedlm(self):
130130
]
131131
assert np.array_equal(spline_nodes, expected_spline_nodes), spline_nodes.tolist()
132132

133+
def test_bwb_lax(self):
134+
bdf_filename = MODEL_PATH / 'bwb' / 'bwb_saero.bdf'
135+
model = BDF(log=None, debug=False)
136+
model.is_strict_card_parser = True
137+
model.read_bdf(bdf_filename, save_file_structure=False)
138+
icd_transform, icp_transform, xyz_cp, nid_cp_cd = model.get_displacement_index_xyz_cp_cd()
139+
model.get_xyz_in_coord_array(cid=0)
140+
133141
def test_bwb(self):
134142
bdf_filename = MODEL_PATH / 'bwb' / 'bwb_saero.bdf'
135143
model = read_bdf(bdf_filename)

pyNastran/f06/dev/flutter/test_gui_flutter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_nastran_utils(self) -> None:
2525
def test_action(self) -> None:
2626
act = Action('cat', 'dog', show=True)
2727
str(act)
28+
2829
def test_load_f06_op2(self) -> None:
2930
f06_filename = MODEL_PATH / 'aero' / '2_mode_flutter' / '0012_flutter.op2'
3031
log = SimpleLogger(level='debug')

pyNastran/f06/test/test_f06_utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,16 @@ def test_plot_flutter_0012_dev(self):
244244
assert len(responses) == 1, responses
245245

246246
f06_filename2 = 'cat.f06'
247-
model, responses = load_f06_op2(f06_filename2, log)
247+
model, responses = load_f06_op2(
248+
f06_filename2, log,
249+
in_units='si', out_units='si', use_rhoref=False)
248250
assert model is None, model
249251
assert len(responses) == 0, responses
250252

251253
f06_filename2 = 'cat.op2'
252-
model, responses = load_f06_op2(f06_filename2, log)
254+
model, responses = load_f06_op2(
255+
f06_filename2, log,
256+
in_units='si', out_units='si', use_rhoref=False)
253257
assert model is None, model
254258
assert len(responses) == 0, responses
255259

0 commit comments

Comments
 (0)