umvarma / pynastran

Automatically exported from code.google.com/p/pynastran
1 stars 0 forks source link

DMIG reader doesn't generate correct matrix for symmetric matrix input #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
bdf.bdf.BDF.read_bdf does not read in symmetric DMIG matrix correctly.

Run the example test.py with the included punch file in the same folder.

Running pyNastran 0.7 dev (r2034). Windows 7.

Example:
=======

from pyNastran.bdf.bdf import BDF

mesh = BDF(debug=False)

# contents of test.pch are as follows:

"""
DMIG    MAAX           0       6       2       0                 1368678
DMIG*   MAAX                           1               1
*                      1               1 1.000000000D+00
DMIG*   MAAX                           1               2
*                      1               1 0.500000000D+00
*                      1               2 2.000000000D+00
DMIG*   MAAX                           1               3
*                      1               1 0.250000000D+00
*                      1               2 0.750000000D+00
*                      1               3 3.000000000D+00
"""

# This defines the symmetric matrix:
#
#    MAAX = [[ 1.  ,  0.5 ,  0.25],
#            [ 0.5 ,  2.  ,  0.75],
#            [ 0.25,  0.75,  3.  ]]
#

mesh.read_bdf('test.pch', xref=False, punch=True)

#
# Am I right that getMatrix should return a numpy array (plus metadata)?
#

dmig_data = mesh.dmigs['MAAX'].getMatrix(isSparse=False)

# On my system, dmig_data is:
#
#  (array([[ 1.  ,  0.5 ,  0.25]]),
#    {0: (1, '1')},
#    {0: (1, '1'), 1: (1, '2'), 2: (1, '3')})

MAAX = dmig_data[0]

print MAAX

# MAAX does not match the intended matrix. It is:

# [[ 1.    0.5   0.25]]

Original issue reported on code.google.com by jeffrey....@gmail.com on 9 May 2014 at 6:55

Attachments:

GoogleCodeExporter commented 9 years ago
The bug should be fixed now.  

One argument was added:
dmig_data = mesh.dmigs['MAAX'].getMatrix(isSparse=False, applySymmetry=True)

applySymmetry is only relevant for matricies with ifo=6.  If it's False, the 
matrix will be an upper triangular matrix and is intended to be used with 
symmetric matrix operations.

In terms of your question "Am I right that getMatrix should return a numpy 
array (plus metadata)?"

getMatrix returns:
(matrix, row_indices, column_indicies) which is necessary because the 
rows/columns are not identified as 1, 2, 3, etc.  They are identified with a 
(grid, component).  If the matrix is not symmetric, the rows and columns can be 
different.

If you want ifo or the raw data, it's part of mesh.dmigs['MAAX'].

Original comment by mesheb82 on 10 May 2014 at 2:18

GoogleCodeExporter commented 9 years ago
closed due to inactivity and no further complaints

Original comment by mesheb82 on 20 Jun 2014 at 4:19