Skip to content

Commit

Permalink
fixing issue SteveDoyle2#326
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Jul 26, 2016
1 parent bd84943 commit f8e7e63
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 11 deletions.
22 changes: 12 additions & 10 deletions pyNastran/bdf/cards/dmig.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def get_row_col_map(GCi, GCj, ifo):
cols = {}
cols_reversed = {}
ndim = len(GCi.shape)
#print('ndim=%s' % ndim)
if ndim == 1:
i = 0
#nrows = np.unique(GCi)
Expand Down Expand Up @@ -449,7 +450,7 @@ def get_row_col_map(GCi, GCj, ifo):
for (nid, comp) in GCi:
GCi = (nid, comp)
if GCi not in rows:
#print('GCi = %s' % str(GCi))
#print('row.GCi = %s' % str(GCi))
rows[GCi] = i
rows_reversed[i] = GCi
i += 1
Expand All @@ -458,20 +459,21 @@ def get_row_col_map(GCi, GCj, ifo):
for (nid, comp) in GCj:
GCj = (nid, comp)
if GCj not in rows:
#print('GCj = %s' % str(GCj))
#print('row.GCj = %s' % str(GCj))
rows[GCj] = i
rows_reversed[i] = GCj
i += 1
cols = rows
cols_reversed = rows_reversed
else:
j = 0
for (nid, comp) in GCj:
GCj = (nid, comp)
if GCj not in cols:
#print('col.GCj = %s' % str(GCj))
cols[GCj] = j
cols_reversed[j] = GCj
j += 1
cols = rows
cols_reversed = rows_reversed

nrows = len(rows)
ncols = len(cols)
Expand Down Expand Up @@ -556,26 +558,26 @@ def _fill_dense_rectangular_matrix(self, nrows, ncols, ndim, rows, cols, apply_s
M[i, j] = reali
except KeyError:
msg = ('name=%s ndim=%s gci=%s gcj=%s matrix_type=%s '
'is_polar=%s is_sparse=%s ncols=%s M.shape=%s\n' % (
'is_polar=%s is_sparse=%s ncols=%s M.shape=%s\n\n' % (
self.name, ndim, str(gci), str(gcj), self.matrix_type,
self.is_polar, is_sparse, self.ncols, M.shape))

gci2 = (gci[0], gci[1])
gcj2 = (gcj[0], gcj[1])
if gci2 in rows:
msg += '\ngci/row_key=%s not found' % str(gci2)
msg += 'gci/row_key=%s found\n' % str(gci2)
else:
msg += '\ngci/row_key=%s not found' % str(gci2)
msg += 'gci/row_key=%s not found\n' % str(gci2)
msg += 'Rows:\n'
for i, row in enumerate(rows):
msg += ' i=%s row=%s\n' % (i, row)

if gcj2 in cols:
msg += '\ngcj/col_key=%s found' % str(gcj2)
msg += '\ngcj/col_key=%s found\n' % str(gcj2)
else:
msg += '\ngcj/col_key=%s not found' % str(gcj2)
msg += '\ngcj/col_key=%s not found\n' % str(gcj2)
msg += 'Cols:\n'
for j, row in enumerate(cols):
for j, col in enumerate(cols):
msg += ' j=%s row=%s\n' % (j, col)

msg += '\n'
Expand Down
159 changes: 159 additions & 0 deletions pyNastran/bdf/cards/test/dmig.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
DMIG KAAX 0 6 2 0 15
DMIG* KAAX 101 1
* 101 1 1.556000000D+02
DMIG* KAAX 102 1
* 101 1-1.556000000D+02
* 102 1 3.815000000D+02
DMIG* KAAX 105 1
* 102 1-2.259000000D+02
* 105 1 5.956800000D+03
DMIG* KAAX 106 1
* 105 1-3.002700000D+03
* 106 1 7.381400000D+03
DMIG* KAAX 107 1
* 106 1-4.378700000D+03
* 107 1 4.378700000D+03
DMIG* KAAX 108 1
* 105 1-2.728200000D+03
* 108 1 2.944900000D+03
DMIG* KAAX 109 1
* 108 1-2.980000000D+01
* 109 1 2.980000000D+01
DMIG* KAAX 201 1
* 108 1-1.869000000D+02
* 201 1 3.738000000D+02
DMIG* KAAX 301 1
* 301 1 1.556000000D+02
DMIG* KAAX 302 1
* 301 1-1.556000000D+02
* 302 1 3.815000000D+02
DMIG* KAAX 305 1
* 302 1-2.259000000D+02
* 305 1 5.956800000D+03
DMIG* KAAX 306 1
* 305 1-3.002700000D+03
* 306 1 7.381400000D+03
DMIG* KAAX 307 1
* 306 1-4.378700000D+03
* 307 1 4.378700000D+03
DMIG* KAAX 308 1
* 201 1-1.869000000D+02
* 305 1-2.728200000D+03
* 308 1 2.944900000D+03
DMIG* KAAX 309 1
* 308 1-2.980000000D+01
* 309 1 2.980000000D+01
DMIG MAAX 0 6 2 0 15
DMIG* MAAX 101 1
* 101 1 1.324200034D+00
DMIG* MAAX 102 1
* 102 1 1.139999949D-03
DMIG* MAAX 105 1
* 105 1 3.570000082D-02
DMIG* MAAX 106 1
* 106 1 8.590000123D-02
DMIG* MAAX 107 1
* 107 1 6.215999722D-01
DMIG* MAAX 108 1
* 108 1 4.100000113D-02
DMIG* MAAX 109 1
* 109 1 2.199999988D-03
DMIG* MAAX 201 1
* 201 1 2.649999969D-02
DMIG* MAAX 301 1
* 301 1 1.324200034D+00
DMIG* MAAX 302 1
* 302 1 1.399999950D-03
DMIG* MAAX 305 1
* 305 1 3.559999913D-02
DMIG* MAAX 306 1
* 306 1 6.970000267D-02
DMIG* MAAX 307 1
* 307 1 6.215999722D-01
DMIG* MAAX 308 1
* 308 1 4.100000113D-02
DMIG* MAAX 309 1
* 309 1 2.199999988D-03
DMIG BAAX 0 6 2 0 15
DMIG* BAAX 101 1
* 101 1 1.000000000D+01
DMIG* BAAX 102 1
* 101 1-1.000000000D+01
* 102 1 1.000000000D+01
DMIG* BAAX 301 1
* 301 1 1.000000000D+01
DMIG* BAAX 302 1
* 301 1-1.000000000D+01
* 302 1 1.000000000D+01
DMIG VAX 0 9 2 0 1
DMIG* VAX 1 0
* 101 1 1.000000000D+00
* 102 1 1.000000000D+00
* 105 1 1.000000000D+00
* 106 1 1.000000000D+00
* 107 1 1.000000000D+00
* 108 1 1.000000000D+00
* 109 1 1.000000000D+00
* 201 1 1.000000000D+00
* 301 1 1.000000000D+00
* 302 1 1.000000000D+00
* 305 1 1.000000000D+00
* 306 1 1.000000000D+00
* 307 1 1.000000000D+00
* 308 1 1.000000000D+00
* 309 1 1.000000000D+00
DMIG RVA 0 9 2 0 2
DMIG* RVA 1 0
* 301 1-3.162277660D+00
* 302 1 3.162277660D+00
DMIG* RVA 2 0
* 101 1-3.162277660D+00
* 102 1 3.162277660D+00
DTI TUG1 0 90 15 32767 0 7 0
PHIP 7 REAL 1ENDREC
DTI TUG1 1 1 0.00000 2 0.00000 3 0.00000
4 0.00000 5 0.00000 6 0.00000 7 0.00000
8 0.00000 9 0.00000 10 0.00000 11 0.00000
12 0.00000 13 0.00000 14 0.00000 15 0.00000
ENDREC
DTI TUG1 2
TYPE ID COMP ROW TYPE ID COMP ROW
1 101 6 1 1 102 6 7
1 105 6 13 1 106 6 19
1 107 6 25 1 108 6 31
1 109 6 37 1 201 6 43
1 301 6 49 1 302 6 55
1 305 6 61 1 306 6 67
1 307 6 73 1 308 6 79
1 309 6 85 ENDREC
DMIG MUG1T 0 9 2 0 90
DMIG* MUG1T 1 0
* 101 1 1.000000000D+00
DMIG* MUG1T 7 0
* 102 1 1.000000000D+00
DMIG* MUG1T 13 0
* 105 1 1.000000000D+00
DMIG* MUG1T 19 0
* 106 1 1.000000000D+00
DMIG* MUG1T 25 0
* 107 1 1.000000000D+00
DMIG* MUG1T 31 0
* 108 1 1.000000000D+00
DMIG* MUG1T 37 0
* 109 1 1.000000000D+00
DMIG* MUG1T 43 0
* 201 1 1.000000000D+00
DMIG* MUG1T 49 0
* 301 1 1.000000000D+00
DMIG* MUG1T 55 0
* 302 1 1.000000000D+00
DMIG* MUG1T 61 0
* 305 1 1.000000000D+00
DMIG* MUG1T 67 0
* 306 1 1.000000000D+00
DMIG* MUG1T 73 0
* 307 1 1.000000000D+00
DMIG* MUG1T 79 0
* 308 1 1.000000000D+00
DMIG* MUG1T 85 0
* 309 1 1.000000000D+00
17 changes: 16 additions & 1 deletion pyNastran/bdf/cards/test/test_dmig.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import os
import pyNastran
from pyNastran.bdf.bdf import BDF, BDFCard, DMIG
from pyNastran.bdf.bdf import BDF, BDFCard, DMIG, read_bdf

from numpy import array, array_equal, sqrt, sin, cos, radians

Expand Down Expand Up @@ -224,6 +224,21 @@ def test_dmig_10(self):
assert a_matrix.shape == (4, 4), 'shape=%s' % str(a_matrix.shape)
a_matrix.get_matrix()

def test_dmig_11(self):
pch_filename = os.path.join(test_path, 'dmig.pch')
model = read_bdf(pch_filename, debug=False, punch=True)
vax = model.dmigs['VAX']
vax_array, vax_dict_row, vax_dict_col = vax.get_matrix()
assert vax_array.shape == (15, 1), vax_array
vax_dict_row_expected = {
0: (101, 1), 1: (102, 1), 2: (105, 1), 3: (106, 1), 4: (107, 1), 5: (108, 1),
6: (109, 1), 7: (201, 1), 8: (301, 1), 9: (302, 1), 10: (305, 1), 11: (306, 1),
12: (307, 1), 13: (308, 1), 14: (309, 1)
}
vax_dict_col_expected = {0: (1, 0)}
assert list(sorted(vax_dict_col)) == list(sorted(vax_dict_col_expected)), 'vax_dict_col=%s vax_dict_col_expected=%s' % (vax_dict_col, vax_dict_col_expected)
assert list(sorted(vax_dict_row)) == list(sorted(vax_dict_row_expected)), 'vax_dict_row=%s vax_dict_row_expected=%s' % (vax_dict_row, vax_dict_row_expected)

def test_dmi_01(self):
data = """
DMI W2GJ 0 2 1 0 1200 1
Expand Down

0 comments on commit f8e7e63

Please sign in to comment.