Skip to content

Commit

Permalink
dmi work
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Nov 26, 2024
1 parent a436f03 commit e127236
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
12 changes: 9 additions & 3 deletions pyNastran/bdf/bdf_interface/add_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions pyNastran/bdf/cards/dmig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions pyNastran/bdf/mesh_utils/test/test_mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.]
Expand All @@ -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)

Expand Down

0 comments on commit e127236

Please sign in to comment.