From e1272363ecd1b25d5ac2d58884133085ba771ff5 Mon Sep 17 00:00:00 2001 From: SteveDoyle2 Date: Mon, 25 Nov 2024 23:37:31 -0800 Subject: [PATCH] dmi work --- pyNastran/bdf/bdf_interface/add_card.py | 12 +++++++++--- pyNastran/bdf/cards/dmig.py | 12 +++++++++--- pyNastran/bdf/mesh_utils/test/test_mesh_utils.py | 6 ++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/pyNastran/bdf/bdf_interface/add_card.py b/pyNastran/bdf/bdf_interface/add_card.py index ae0874a4b..f2739f13e 100644 --- a/pyNastran/bdf/bdf_interface/add_card.py +++ b/pyNastran/bdf/bdf_interface/add_card.py @@ -9048,7 +9048,8 @@ def add_dmi_w2gj(self, tin: int, tout: int, nrows: int, self._add_methods._add_dmi_object(dmi) return dmi - def add_dmi(self, name: str, form: int, tin: int, tout: int, nrows: int, ncols: int, + def add_dmi(self, name: str, form: int, tin: int, tout: int, + nrows: int, ncols: int, GCj, GCi, Real, Complex=None, comment: str='') -> DMI: """Creates a DMI card @@ -9099,7 +9100,11 @@ def add_dense_dmi(self, name: str, myarray: np.ndarray, else: # pragma: no cover raise NotImplementedError(str_form) - GCi = np.repeat(list(range(1, nrows+1)), ncols, axis=0).reshape(nrows, ncols) + # ncols = 2 + GC = np.repeat(list(range(1, nrows+1)), ncols, axis=0) + # print('GC =', GC) + GCi = GC.reshape(nrows, ncols) + # print('GCi =', GCi) GCj = GCi.T.flatten() GCi = GCi.flatten() @@ -9115,7 +9120,8 @@ def add_dense_dmi(self, name: str, myarray: np.ndarray, dmi.validate() return dmi - def add_dmiax(self, name, matrix_form, tin, tout, ncols, + def add_dmiax(self, name: str, matrix_form: int, + tin: int, tout: int, ncols: int, GCNj, GCNi, Real, Complex=None, comment='') -> DMIAX: """Creates a DMIAX card""" dmiax = DMIAX(name, matrix_form, tin, tout, ncols, diff --git a/pyNastran/bdf/cards/dmig.py b/pyNastran/bdf/cards/dmig.py index f4eb86fdc..a648cfd55 100644 --- a/pyNastran/bdf/cards/dmig.py +++ b/pyNastran/bdf/cards/dmig.py @@ -2747,9 +2747,15 @@ def get_dmi_matrix(matrix: DMI, # rectangular nrows = matrix.nrows ncols = matrix.ncols - - M = coo_matrix((data, (GCi, GCj)), - shape=(nrows, ncols), dtype=dtype) + try: + M = coo_matrix((data, (GCi, GCj)), + shape=(nrows, ncols), dtype=dtype) + except ValueError: + print(f'nrows, cols = ({nrows}, {ncols})') + print('data = ', data) + print('GCi = ', GCi) + print('GCj = ', GCj) + raise else: nrows = matrix.nrows ncols = matrix.ncols diff --git a/pyNastran/bdf/mesh_utils/test/test_mesh_utils.py b/pyNastran/bdf/mesh_utils/test/test_mesh_utils.py index 157e00119..4808ca931 100644 --- a/pyNastran/bdf/mesh_utils/test/test_mesh_utils.py +++ b/pyNastran/bdf/mesh_utils/test/test_mesh_utils.py @@ -165,7 +165,7 @@ def test_exit(self): cmd_line(argv=['bdf', cmd], quiet=True) def test_export_caero_mesh_caero1_wkk(self): - model = BDF() + model = BDF(debug=None) model.bdf_filename = 'test' p1 = [0., 0., 0.] p4 = [0., 1., 0.] @@ -191,7 +191,9 @@ def test_export_caero_mesh_caero1_wkk(self): tin, tout, nrows, ncols, GCj, GCi, Real, Complex=None, comment='wkk') - #argv = ['bdf', 'export_caero_mesh', bdf_filename, '-o', path / 'cpmopt.paero.bdf', '--pid', 'caero', '--subpanels'] + + real_array = np.ones((len(Real), 1)) + #model.add_dense_dmi(name+'2', real_array, form, validate=True) export_caero_mesh(model, is_subpanel_model=True, ) save_load_deck(model, run_remove_unused=False)