Skip to content

Commit

Permalink
* bdf:
Browse files Browse the repository at this point in the history
 - EIGR can use method=LAN (lancoz) with nd=None if f1/f2

bdf_vectorized3:
 - adding:
   - CPENTCZ, PSOLCZ, CIFPENT, CIFHEX cohesive zone cards
   - MATT2, TABDMP1
   - TABRND1 (table_sdamping)
   - VIEW, VIEW3D, RADCAV
 - bug fixes:
   - fixed lmach -> aeqr bug
   - fixed NSM1 card length bug
   - more failure theories for PCOMPS
   - fixed PAERO5 slice bug
   - fixed NSM write bug
   - fixed some return value for add_card (should be self.n-1)
   - fixed DDVAL.add method
   - model.add_flutter works
 - BCBODY in work:
   - supports first 2 lines and RIGID
   - supports large field
 - working on apply_slice
 - generalizing sort_duplicates
   - can now filter duplicate PSHELL, PCOMP, PCOMPG, PBAR, PBARL, PBEAM, PBEAML, PSOLID, PLSOLID, PROD, PTUBE, MAT1
   - sort supports strings
 - more duplicate card removal
  - _skip_equality_check short circuits cards that have variable length parameters (so PBAR no, PBARL yes)
 - i -> icard
 - more checks enabled in test_bdf
 - adding flags to disable nan checks
  • Loading branch information
SteveDoyle2 committed Dec 22, 2023
1 parent a11997f commit c9588fa
Show file tree
Hide file tree
Showing 58 changed files with 4,295 additions and 1,766 deletions.
12 changes: 9 additions & 3 deletions pyNastran/bdf/bdf_interface/assign_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ def integer(card: BDFCard, ifield: int, fieldname: str) -> int:
raise SyntaxError('%s = %r (field #%s) on card must be an integer (not %s).\n'
'card=%s' % (fieldname, svalue, ifield, dtype, card))

def integer_or_blank(card: BDFCard, ifield: int, fieldname: str, default: Optional[int]=None) -> int:
def integer_or_blank(card: BDFCard, ifield: int, fieldname: str,
default: Optional[int]=None) -> int:
"""
Casts a value to an integer
Expand All @@ -404,6 +405,7 @@ def integer_or_blank(card: BDFCard, ifield: int, fieldname: str, default: Option
elif svalue is None:
return default
elif isinstance(svalue, str):
svalue = svalue.strip()
if len(svalue) == 0:
return default
elif '.' in svalue or '-' in svalue[1:] or '+' in svalue[1:]:
Expand Down Expand Up @@ -770,6 +772,9 @@ def integer_double_or_blank(card: BDFCard, ifield: int, fieldname: str, default=
return default

if svalue:
svalue = svalue.strip()
if svalue == '':
return default
# integer/float
try:
return integer_or_double(card, ifield, fieldname)
Expand Down Expand Up @@ -815,6 +820,7 @@ def integer_or_string(card: BDFCard, ifield: int, fieldname: str) -> Union[int,
except ValueError:
pass

svalue = svalue.strip()
if svalue[0].isdigit():
dtype = _get_dtype(svalue)
raise SyntaxError('%s = %r (field #%s) on card must be an integer or string (not %s; '
Expand Down Expand Up @@ -1063,7 +1069,7 @@ def string_or_blank(card: BDFCard, ifield: int, fieldname: str, default=None):
if ' ' in svalue:
raise SyntaxError('%s = %r (field #%s) on card must be a string without a space.\n'
'card=%s' % (fieldname, svalue, ifield, card))
if svalue[0].isdigit() or '.' in svalue or '+' in svalue or '-' in svalue[0]:
if len(svalue) and (svalue[0].isdigit() or '.' in svalue or '+' in svalue or '-' in svalue[0]):
chars = ''.join(list(set('%s.+-' % svalue[0] if svalue[0].isdigit() else '')))
raise SyntaxError('%s = %r (field #%s) on card must not have the '
'following characters %s\n'
Expand All @@ -1074,7 +1080,7 @@ def string_or_blank(card: BDFCard, ifield: int, fieldname: str, default=None):
'card=%s' % (fieldname, svalue, ifield, dtype, card))

svalue = svalue.strip()
if svalue.isdigit() or '.' in svalue or '+' in svalue or '-' in svalue[0]:
if len(svalue) and (svalue.isdigit() or '.' in svalue or '+' in svalue or '-' in svalue[0]):
# integer or float
dtype = _get_dtype(svalue)
raise SyntaxError('%s = %r (field #%s) on card must be a string or blank (not %s).\n'
Expand Down
16 changes: 11 additions & 5 deletions pyNastran/bdf/bdf_interface/assign_type_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def force_integer_or_blank(card: BDFCard, ifield: int, fieldname: str,
raise SyntaxError('%s = %r (field #%s) on card must be an integer (not %s).\n'
'card=%s' % (fieldname, svalue, ifield, dtype, card))

def force_double_or_blank(card: BDFCard, ifield: int, fieldname: str, default: Optional[float]=None):
def force_double_or_blank(card: BDFCard, ifield: int, fieldname: str,
default: Optional[float]=None):
"""see ``double_or_blank``"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -164,7 +165,7 @@ def force_double_or_blank(card: BDFCard, ifield: int, fieldname: str, default: O
'card=%s' % (fieldname, svalue, ifield, dtype, card))
return default

def force_double_or_string(card: BDFCard, ifield: int, fieldname: str, default: Optional[float]=None):
def force_double_or_string(card: BDFCard, ifield: int, fieldname: str):
"""see ``double_or_string``"""
svalue = card.field(ifield)

Expand All @@ -175,6 +176,7 @@ def force_double_or_string(card: BDFCard, ifield: int, fieldname: str, default:
warnings.warn('%s = %r (field #%s) on card must be a float or string (not an integer) -> %s.\n'
'card=%s' % (fieldname, svalue, ifield, card))
return fvalue

elif isinstance(svalue, str):
if len(svalue) == 0:
warnings.warn('%s = %r (field #%s) on card must be a float or string (not an blank) -> %s.\n'
Expand Down Expand Up @@ -209,9 +211,13 @@ def force_double_or_string(card: BDFCard, ifield: int, fieldname: str, default:
#raise SyntaxError('%s = %r (field #%s) on card must be a float or blank (not %s).\n'
#'card=%s' % (fieldname, svalue, ifield, dtype, card))
else:
raise SyntaxError('%s = %r (field #%s) on card must be a float or blank (not an integer) -> %s.\n'
'card=%s' % (fieldname, svalue, ifield, card))
return default
dtype = _get_dtype(svalue)
raise SyntaxError('%s = %r (field #%s) on card must be a float or string (not %s).\n'
'card=%s' % (fieldname, svalue, ifield, dtype, card))

raise SyntaxError('%s = %r (field #%s) on card must be a float or string -> %s.\n'
'card=%s' % (fieldname, svalue, ifield, dtype, card))
#return default

def lax_double_or_blank(card: BDFCard, ifield: int, fieldname: str,
default: Optional[float]=None,
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def parse_executive_control_deck(
sline = uline.strip().split()
assert len(sline) == 2, sline
app = sline[1]
assert app in {'HEAT', 'DISP', 'COUPLED', 'DISPLACEMENT'}, f'uline={uline!r}'
assert app in {'HEAT', 'DISP', 'COUPLED', 'DISPLACEMENT', 'DMAP'}, f'uline={uline!r}'
return sol, method, sol_iline, app


Expand Down
8 changes: 5 additions & 3 deletions pyNastran/bdf/cards/bdf_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from pyNastran.bdf.bdf_interface.assign_type_force import force_double_or_string
if TYPE_CHECKING:
from pyNastran.bdf.bdf import BDF
from pyNastran.bdf.bdf_interface.bdf_card import BDFCard


def make_xy(table_id, table_type, xy):
Expand Down Expand Up @@ -2007,7 +2008,7 @@ def _map_axis(axis):
raise ValueError('axis=%r' % axis)
return axis_type

def read_table(card, table_id: int, table_type: str) -> tuple[np.ndarray, np.ndarray]:
def read_table(card: BDFCard, table_id: int, table_type: str) -> tuple[np.ndarray, np.ndarray]:
"""common method for reading tables that handles SKIP"""
nfields = len(card) - 1
nterms = (nfields - 9) // 2
Expand All @@ -2028,7 +2029,8 @@ def read_table(card, table_id: int, table_type: str) -> tuple[np.ndarray, np.nda
x, y = make_xy(table_id, table_type, xy)
return x, y

def read_table_lax(card, table_id: int, table_type: str) -> tuple[np.ndarray, np.ndarray]:
def read_table_lax(card: BDFCard, table_id: int,
table_type: str) -> tuple[np.ndarray, np.ndarray]:
"""common method for reading tables that handles SKIP"""
nfields = len(card) - 1
nterms = (nfields - 9) // 2
Expand All @@ -2049,7 +2051,7 @@ def read_table_lax(card, table_id: int, table_type: str) -> tuple[np.ndarray, np
x, y = make_xy(table_id, table_type, xy)
return x, y

def read_table_float_int(card, table_id, table_type):
def read_table_float_int(card: BDFCard, table_id: int, table_type: str):
"""common method for reading tables that handles SKIP"""
nfields = len(card) - 1
nterms = (nfields - 9) // 2
Expand Down
Loading

0 comments on commit c9588fa

Please sign in to comment.