Skip to content

Commit

Permalink
splitting out QualInfo; more flags
Browse files Browse the repository at this point in the history
fixing beta_n method
  • Loading branch information
SteveDoyle2 committed Mar 13, 2023
1 parent c4bd676 commit dc06aa0
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 131 deletions.
6 changes: 3 additions & 3 deletions pyNastran/bdf/cards/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,10 @@ def beta_n(self, n: int):
"""
assert n < 10, 'n=%r' % n
matrix = self.beta()
t = np.zeros((3*n, 3*n), dtype='float64') # transformation matrix
xform = np.zeros((3*n, 3*n), dtype='float64') # transformation matrix
for i in range(n):
t[i*3:i*3+2, i*3:i*3+2] = matrix[0:2, 0:2]
return t
xform[i*3:i*3+3, i*3:i*3+3] = matrix
return xform


def transform_matrix_to_global(self, matrix):
Expand Down
20 changes: 12 additions & 8 deletions pyNastran/converters/nastran/gui/nastran_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
from cpylog import SimpleLogger
from pyNastran.gui.gui_objects.settings import Settings, NastranSettings
from pyNastran.gui.main_window import MainWindow
from pyNastran.bdf.bdf import MONPNT1, CORD2R, AECOMP, SET1

SIDE_MAP = {}
SIDE_MAP['CHEXA'] = {
Expand Down Expand Up @@ -3025,7 +3026,7 @@ def map_elements(self, xyz_cid0, nid_cp_cd, nid_map, model, j, dim_max,
self.normals = normals
return nid_to_pid_map, icase, cases, form

def _build_mcid_vectors(self, model: BDF, nplies: int):
def _build_mcid_vectors(self, model: BDF, nplies: int) -> None:
"""creates the shell material coordinate vectors"""
etype = 3 # vtkLine

Expand Down Expand Up @@ -5224,7 +5225,11 @@ def _build_properties(self, model: BDF, nelements: int,
nplies = nplies_pcomp.max()

if nastran_settings.is_shell_mcids and nplies is not None:
self._build_mcid_vectors(model, nplies)
try:
self._build_mcid_vectors(model, nplies)
except Exception as exception:
model.log.error(str(exception))

return icase, upids, pcomp, pshell, (is_pshell, is_pcomp)

def _plot_pressures(self, model: BDF, cases, form0,
Expand Down Expand Up @@ -7214,19 +7219,18 @@ def _create_monpnt(gui: MainWindow,
model: BDF,
xyz_cid0: np.ndarray,
nid_cp_cd: np.ndarray):
from pyNastran.bdf.bdf import MONPNT1, CORD2R, AECOMP, SET1
cell_type_point = 1 # vtk.vtkVertex().GetCellType()

all_nids = nid_cp_cd[:, 0]
log = model.log
for monpnt in model.monitor_points:
monpnt = monpnt # type: MONPNT1
coord = model.coords[monpnt.cp]
coord = coord # type: CORD2R
monpnt: MONPNT1 = monpnt
coord: CORD2R = model.coords[monpnt.cp]
coord = coord
xyz_global = coord.transform_node_to_global(monpnt.xyz).reshape(1, 3)
label = monpnt.label
try:
aecomp = model.aecomps[monpnt.comp] # type: AECOMP
aecomp: AECOMP = model.aecomps[monpnt.comp]
except KeyError:
key = monpnt.comp
keys = list(model.aecomps.keys())
Expand All @@ -7238,7 +7242,7 @@ def _create_monpnt(gui: MainWindow,
#set1_ids = aecomp.lists
nids = []
for set1_id in aecomp.lists:
set1 = model.sets[set1_id] # type: SET1
set1: SET1 = model.sets[set1_id]
nids += set1.ids

nids = np.unique(nids)
Expand Down
121 changes: 1 addition & 120 deletions pyNastran/op2/op2_interface/op2_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from pyNastran.op2.result_objects.matrix import Matrix
from pyNastran.op2.result_objects.matrix_dict import MatrixDict
from pyNastran.op2.result_objects.design_response import DSCMCOL
from pyNastran.op2.result_objects.qualinfo import QualInfo
from pyNastran.op2.op2_interface.msc_tables import MSC_GEOM_TABLES
from pyNastran.op2.op2_interface.nx_tables import NX_GEOM_TABLES

Expand Down Expand Up @@ -107,126 +108,6 @@ class SubTableReadError(Exception):
'MGPFO', 'MEF1', 'MEF1O', 'MQG1', 'MQG1O', 'MQMG1', 'MQMG1O',
]

class QualInfo:
def __init__(self,
AUXMID=0,
AFPMID=0,
DESITER=0,
HIGHQUAL=0,
DESINC=0,
MASSID=0,
ARBMID=0,
PARTNAME=' ',
TRIMID=0,
MODULE=0,
FLXBDYID=0,
DFPHASE=' ',
ISOLAPP=0,
#ISOLAPP=1,
SEID=0,
PEID=0,

DISCRETE=False,
PRESEQP=False,
DELTA=False,
BNDSHP=False,
ADJOINT=False,
APRCH=' ',
QCPLD=' ',
DBLOCFRM=' ',
P2G=' ',
K2GG=' ',
M2GG=' ',
CASEF06=' ',

NL99=0,
MTEMP=0,
SUBCID=0,
#OSUBID=1,
OSUBID=0,
STEPID=0,
RGYRO=0,
SSTEPID=0,
):
# ints
self.AUXMID = AUXMID
self.AFPMID = AFPMID
self.DESITER = DESITER
self.HIGHQUAL = HIGHQUAL
self.DESINC = DESINC
self.MASSID = MASSID
self.ARBMID = ARBMID
self.TRIMID = TRIMID
self.MODULE = MODULE

# booleans
self.DISCRETE = DISCRETE
self.PRESEQP = PRESEQP
self.DELTA = DELTA
self.BNDSHP = BNDSHP
self.ADJOINT = ADJOINT

# strings
self.PARTNAME = PARTNAME
self.DFPHASE = DFPHASE
self.APRCH = APRCH
self.QCPLD = QCPLD
self.DBLOCFRM = DBLOCFRM
self.P2G = P2G
self.K2GG = K2GG
self.M2GG = M2GG
self.CASEF06 = CASEF06

# other
self.FLXBDYID = FLXBDYID
self.ISOLAPP = ISOLAPP
self.SEID = SEID
self.PEID = PEID
self.NL99 = NL99
self.MTEMP = MTEMP
self.SUBCID = SUBCID
self.OSUBID = OSUBID
self.STEPID = STEPID
self.RGYRO = RGYRO
self.SSTEPID = SSTEPID

@classmethod
def from_str(self, db_key: int, qual_str: str, log):
assert qual_str[0] == '(', f'qual_str={qual_str!r}'
assert qual_str[-1] == ')', f'qual_str={qual_str!r}'
qual_str2 = qual_str[1:-1]
slines = qual_str2.split(';')

def _parse(slines: list[str], debug: bool=False) -> dict[str, Any]:
data_dict = {}
for i, sline in enumerate(slines):
key, value = sline.split('=', 1)
if value == 'FALSE':
value = False
elif value == "TRUE":
value = True
elif value == "' '":
value = ''
else:
value = value.strip()
if value.isdigit():
value = int(value)
if debug:
log.warning(f'{key}={value!r},')
data_dict[key] = value
return data_dict

data_dict = _parse(slines, debug=False)
try:
qual_info = QualInfo(**data_dict)
except TypeError as exception:
qual_info = QualInfo()
log.debug(f'{db_key: 7d} {qual_str}')
data_dict = _parse(slines, debug=True)
log.error(str(exception))
#raise
return qual_info


class OP2Reader:
"""Stores methods that aren't useful to an end user"""
Expand Down
132 changes: 132 additions & 0 deletions pyNastran/op2/result_objects/qualinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from typing import Any


class QualInfo:
def __init__(self,
AUXMID=0,
AFPMID=0,
DESITER=0,
HIGHQUAL=0,
DESINC=0,
MASSID=0,
ARBMID=0,
TRIMID=0,
MODULE=0,
FLXBDYID=0,
ISOLAPP=0,
#ISOLAPP=1,
SEID=0,
PEID=0,

DISCRETE=False,
PRESEQP=False,
DELTA=False,
BNDSHP=False,
ADJOINT=False,
APRCH=' ',
PARTNAME=' ',
DFPHASE=' ',
QCPLD=' ',
DBLOCFRM=' ',
P2G=' ',
K2GG=' ',
M2GG=' ',
CASEF06=' ',

NL99=0,
MTEMP=0,
SUBCID=0,
#OSUBID=1,
OSUBID=0,
STEPID=0,
RGYRO=0,
SSTEPID=0,
#----------------------------------
PRELOAD=0,
MPC=0,
SPC=0,
SUPORT=0,
BMETH=0,
NLOOP=0,
STATSUB=0,
):
# ints
self.AUXMID = AUXMID
self.AFPMID = AFPMID
self.DESITER = DESITER
self.HIGHQUAL = HIGHQUAL
self.DESINC = DESINC
self.MASSID = MASSID
self.ARBMID = ARBMID
self.TRIMID = TRIMID
self.MODULE = MODULE

# booleans
self.DISCRETE = DISCRETE
self.PRESEQP = PRESEQP
self.DELTA = DELTA
self.BNDSHP = BNDSHP
self.ADJOINT = ADJOINT

# strings
self.PARTNAME = PARTNAME
self.DFPHASE = DFPHASE
self.APRCH = APRCH
self.QCPLD = QCPLD
self.DBLOCFRM = DBLOCFRM
self.P2G = P2G
self.K2GG = K2GG
self.M2GG = M2GG
self.CASEF06 = CASEF06

# other
self.FLXBDYID = FLXBDYID
self.ISOLAPP = ISOLAPP
self.SEID = SEID
self.PEID = PEID
self.NL99 = NL99
self.MTEMP = MTEMP
self.SUBCID = SUBCID
self.OSUBID = OSUBID
self.STEPID = STEPID
self.RGYRO = RGYRO
self.SSTEPID = SSTEPID

@classmethod
def from_str(self, db_key: int, qual_str: str, log):
assert qual_str[0] == '(', f'qual_str={qual_str!r}'
assert qual_str[-1] == ')', f'qual_str={qual_str!r}'
qual_str2 = qual_str[1:-1]
slines = qual_str2.split(';')

def _parse(slines: list[str], debug: bool=False) -> dict[str, Any]:
data_dict = {}
for i, sline in enumerate(slines):
key, value_str = sline.split('=', 1)
if value_str == 'FALSE':
value = False
elif value_str == "TRUE":
value = True
elif value_str == "' '":
value = ''
else:
value_str = value_str.strip()
if value_str.isdigit():
value = int(value_str)
else:
value = value_str
if debug:
log.warning(f'{key}={value!r},')
data_dict[key] = value
return data_dict

data_dict = _parse(slines, debug=False)
try:
qual_info = QualInfo(**data_dict)
except TypeError as exception:
qual_info = QualInfo()
log.debug(f'{db_key: 7d} {qual_str}')
data_dict = _parse(slines, debug=True)
log.error(str(exception))
#raise
return qual_info

0 comments on commit dc06aa0

Please sign in to comment.