Skip to content

Commit

Permalink
bdf:
Browse files Browse the repository at this point in the history
 - typing
 - fixed matcid to be easier to use; added tests
 - added test for MATT11

flutter:
 - added frequency
  • Loading branch information
SteveDoyle2 committed Nov 17, 2024
1 parent db06f63 commit 2df767e
Show file tree
Hide file tree
Showing 88 changed files with 471 additions and 346 deletions.
15 changes: 6 additions & 9 deletions pyNastran/bdf/bdf_interface/add_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -3767,11 +3767,11 @@ def add_matt11(self, mid: int,
self._add_methods._add_material_dependence_object(mat)
return mat

def add_matcid(self, cid: int, form: int,
eids = None,
start: Optional[int] = None,
thru: Optional[int] = None,
by: Optional[int] = None,
def add_matcid(self, cid: int,
eids: list[int]=None,
start: Optional[int]=None,
thru: Optional[int]=None,
by: int=1,
comment: str='') -> MATCID:
"""
Creates the MATCID card, which defines the Material Coordinate
Expand All @@ -3788,9 +3788,6 @@ def add_matcid(self, cid: int, form: int,
----------
cid : int
coordinate system id
form: int
integer indicating the format alternative (for reference,
see the 4 different formats below)
eids : array[int, ...]
Array of element identification numbers
start: int
Expand Down Expand Up @@ -3833,7 +3830,7 @@ def add_matcid(self, cid: int, form: int,
+--------+-------+--------+-------+-------+------+------+------+------+
"""

matcid = MATCID(cid, form, eids, start, thru, by, comment=comment)
matcid = MATCID(cid, eids, start, thru, by, comment=comment)
self._add_methods._add_matcid_object(matcid)
return matcid

Expand Down
6 changes: 3 additions & 3 deletions pyNastran/bdf/bdf_interface/add_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,10 @@ def _add_matcid_object(self, matcid: MATCID) -> None:
assert matcid.cid > -1, 'cid=%s coord=\n%s' % (key, matcid)

# Multiple MATCIDs can share the same CID
if key in self.model.MATCID:
self.model.MATCID[key].append(matcid)
if key in self.model.matcid:
self.model.matcid[key].append(matcid)
else:
self.model.MATCID[key] = [matcid]
self.model.matcid[key] = [matcid]
self.model._type_to_id_map[matcid.type].append(key)

def _add_load_combination_object(self, load: LOAD | CLOAD) -> None:
Expand Down
6 changes: 4 additions & 2 deletions pyNastran/bdf/bdf_interface/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
MATS1, MATS3, MATS8,
MATCID, MATHE, MATHP,
#MATT1, MATT2, MATT3, MATT4, MATT5, MATT8, MATT9, MATT11,
MATDMG,
MATDMG, MATCID,
NXSTRAT,
PMASS, CONM1, CONM2, CMASS1, CMASS2, CMASS3, CMASS4, CMASS5,
NSMs, NSMADD,
Expand Down Expand Up @@ -533,6 +533,8 @@ def __init_attributes(self) -> None:
self.MATDMG: dict[int, MATDMG] = {}
self.nxstrats: dict[int, NXSTRAT] = {}

self.matcid: dict[int, MATCID] = {}

#: stores the CREEP card
self.creep_materials: dict[int, CREEP] = {}

Expand All @@ -553,7 +555,7 @@ def __init_attributes(self) -> None:
xzplane = array([1., 0., 0.])
coord = CORD2R(cid=0, rid=0, origin=origin, zaxis=zaxis, xzplane=xzplane)
self.coords: dict[int, Coord] = {0 : coord}
self.MATCID: dict[int, MATCID] = {}
self.matcid: dict[int, MATCID] = {}

# --------------------------- constraints ----------------------------
#: stores SUPORT1s
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/cross_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

import numpy as np
from pyNastran.bdf.bdf_interface.attributes import BDFAttributes
if TYPE_CHECKING:
if TYPE_CHECKING: # pragma: no cover
from pyNastran.bdf.bdf import BDF
from pyNastran.bdf.bdf_interface.cross_reference_obj import CrossReference

Expand Down
88 changes: 44 additions & 44 deletions pyNastran/bdf/bdf_interface/cross_reference_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,13 @@ def cross_reference_masses(self) -> None:
for mass in model.masses.values():
try:
mass.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mass)

for prop in model.properties_mass.values():
try:
prop.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, prop)

def safe_cross_reference_masses(self) -> None:
Expand All @@ -497,13 +497,13 @@ def safe_cross_reference_masses(self) -> None:
for mass in model.masses.values():
try:
mass.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mass)

for prop in model.properties_mass.values():
try:
prop.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, prop)

def cross_reference_elements(self) -> None:
Expand All @@ -515,13 +515,13 @@ def cross_reference_elements(self) -> None:
for elem in model.elements.values():
try:
elem.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, elem)

for elem in model.masses.values():
try:
elem.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, elem)

def safe_cross_reference_elements(self) -> None:
Expand Down Expand Up @@ -559,13 +559,13 @@ def cross_reference_rigid_elements(self) -> None:
for elem in model.rigid_elements.values():
try:
elem.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, elem)

for elem in model.plotels.values():
try:
elem.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, elem)

def cross_reference_properties(self) -> None:
Expand All @@ -574,7 +574,7 @@ def cross_reference_properties(self) -> None:
for prop in model.properties.values():
try:
prop.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, prop)

def safe_cross_reference_properties(self) -> None:
Expand All @@ -585,12 +585,12 @@ def safe_cross_reference_properties(self) -> None:
if hasattr(prop, 'safe_cross_reference'):
try:
prop.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, prop)
else:
try:
prop.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, prop)

def cross_reference_materials(self) -> None:
Expand All @@ -602,13 +602,13 @@ def cross_reference_materials(self) -> None:
for mat in model.materials.values(): # MAT1
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)

for mat in model.creep_materials.values(): # CREEP
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)

# CREEP - depends on MAT1
Expand All @@ -619,7 +619,7 @@ def cross_reference_materials(self) -> None:
for mat in material_deps.values():
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)

def safe_cross_reference_materials(self) -> None:
Expand All @@ -631,22 +631,22 @@ def safe_cross_reference_materials(self) -> None:
xref_errors = defaultdict(list)
missing_safe_xref = set()
for mat in model.materials.values(): # MAT1
if hasattr(mat, 'safe_cross_reference'):
try:
mat.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
self._store_xref_error(error, mat)
else:
missing_safe_xref.add(mat.type)
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
self._store_xref_error(error, mat)
#if hasattr(mat, 'safe_cross_reference'):
try:
mat.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)
# else:
# missing_safe_xref.add(mat.type)
# try:
# mat.cross_reference(model)
# except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
# self._store_xref_error(error, mat)

for mat in model.creep_materials.values(): # CREEP
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)

# CREEP - depends on MAT1
Expand All @@ -655,17 +655,17 @@ def safe_cross_reference_materials(self) -> None:
model.MATT8, model.MATT9, model.MATT11]
for material_deps in data:
for mat in material_deps.values():
if hasattr(mat, 'safe_cross_reference'):
try:
mat.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
self._store_xref_error(error, mat)
else:
missing_safe_xref.add(mat.type)
try:
mat.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
self._store_xref_error(error, mat)
#if hasattr(mat, 'safe_cross_reference'):
try:
mat.safe_cross_reference(model, xref_errors)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, mat)
# else:
# missing_safe_xref.add(mat.type)
# try:
# mat.cross_reference(model)
# except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
# self._store_xref_error(error, mat)

self._show_safe_xref_errors('materials', xref_errors)
if missing_safe_xref:
Expand Down Expand Up @@ -700,22 +700,22 @@ def cross_reference_loads(self) -> None:
for load_combination in load_combinations:
try:
load_combination.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, load_combination)

for (unused_lid, loads) in model.loads.items():
for load in loads:
try:
load.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, load)

for (unused_lid, sid) in model.dloads.items():
for load in sid:
#self.log.debug(" dloadi load=%s" % (load))
try:
load.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._ixref_errors += 1
var = traceback.format_exception_only(type(error), error)
self._stored_xref_errors.append((load, var))
Expand All @@ -727,26 +727,26 @@ def cross_reference_loads(self) -> None:
#self.log.debug(" dloadi load=%s" % (load))
try:
load.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
#raise
self._store_xref_error(error, load)

for unused_key, darea in model.dareas.items():
try:
darea.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, darea)

for unused_key, tic in model.tics.items():
try:
tic.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, tic)

for unused_key, dphase in model.dphases.items():
try:
dphase.cross_reference(model)
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error:
except (SyntaxError, RuntimeError, AssertionError, KeyError, ValueError) as error: # pragma: no cover
self._store_xref_error(error, dphase)

def safe_cross_reference_loads(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_bdf_stats(model: BDF, return_type: str='string',
'MATT1', 'MATT2', 'MATT3', 'MATT4', 'MATT5',
'MATT8', 'MATT9', 'MATT11',
'MATS1', 'MATS3', 'MATS8',
'MATCID', 'MATDMG',
'matcid', 'MATDMG',

# axisysmmetric
'ringaxs', 'ringfl',
Expand Down
4 changes: 2 additions & 2 deletions pyNastran/bdf/bdf_interface/write_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ def _write_matcids(self, bdf_file: Any, size: int=8, is_double: bool=False,
"""Writes the MATCID cards in a sorted order"""
size, is_long_ids = self._write_mesh_long_ids_size(size, is_long_ids)

if len(self.MATCID):
if len(self.matcid):
bdf_file.write('$MATCID\n')
for (cid, matcids) in sorted(self.MATCID.items()):
for (cid, matcids) in sorted(self.matcid.items()):
for matcid in matcids:
try:
bdf_file.write(matcid.write_card(size, is_double))
Expand Down
Loading

0 comments on commit 2df767e

Please sign in to comment.